-
Notifications
You must be signed in to change notification settings - Fork 1
Home
Splamy edited this page Nov 4, 2017
·
1 revision
Special options can be set in template directives with the following syntax:
<#@ directive_name property="value" property2="value" ... #>
Used to enable debug output within the template:
<#@ template debug="true" #>
Change this file, and the next `cargo build` will notice.
My Name is: <#= self.name #>.
will show how the template is parsed and translated:
Rest: "\nChange this file, and the next `cargo build` will notice.\nMy Name is: <#= self.name #>."
take text: "\nChange this file, and the next `cargo build` will notice.\nMy Name is: " Rest: Ok("<#= self.name #>.")
take text: ""
expression start take code: " self.name " code end Rest: "."
Rest: ""
Template ok!
Generated Code:
f.write_str(r#"
Change this file, and the next `cargo build` will notice.
My Name is: "#)?;
write!(f, "{}", self.name )?;
f.write_str(r#"."#)?;
Used to remove lines which only have leading spaces and code blocks:
<#@ template cleanws="true" #>
My template
<# for i in 0..3 { #>
looks nice
<# } #>
will become
cleanws="true" | cleanws="false" |
---|---|
My template |
My template |