This repository has been archived by the owner on Jun 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
113 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
use proc_macro2::TokenStream; | ||
use syn::{parse::Parse, FieldValue}; | ||
|
||
use crate::{ | ||
args::{self}, | ||
template, | ||
}; | ||
|
||
pub struct ExpandTokens { | ||
pub input: TokenStream, | ||
} | ||
|
||
struct Args {} | ||
|
||
impl Parse for Args { | ||
fn parse(input: syn::parse::ParseStream) -> syn::Result<Self> { | ||
args::set_from_field_values( | ||
input.parse_terminated(FieldValue::parse, Token![,])?.iter(), | ||
[], | ||
)?; | ||
|
||
Ok(Args {}) | ||
} | ||
} | ||
|
||
pub fn expand_tokens(opts: ExpandTokens) -> Result<TokenStream, syn::Error> { | ||
let (_, template, props) = template::parse2::<Args>(opts.input, true)?; | ||
|
||
let props_match_input_tokens = props.match_input_tokens(); | ||
let props_match_binding_tokens = props.match_binding_tokens(); | ||
let props_tokens = props.match_bound_tokens(); | ||
|
||
let template_tokens = template.template_tokens(); | ||
|
||
Ok(quote!({ | ||
match (#(#props_match_input_tokens),*) { | ||
(#(#props_match_binding_tokens),*) => { | ||
emit::__private::__private_format( | ||
#template_tokens, | ||
#props_tokens, | ||
) | ||
} | ||
} | ||
})) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters