pub struct TmplGroup { /* private fields */ }
Expand description
A template group in which the templates can ref each other.
Implementations§
Source§impl TmplGroup
impl TmplGroup
Sourcepub fn import_group(&mut self, group: &TmplGroup)
pub fn import_group(&mut self, group: &TmplGroup)
import another group.
Sourcepub fn get_tree(&self, path: &str) -> Result<&Template, TmplError>
pub fn get_tree(&self, path: &str) -> Result<&Template, TmplError>
Add a ref of a parsed tree in the group.
Sourcepub fn get_tree_mut(&mut self, path: &str) -> Result<&mut Template, TmplError>
pub fn get_tree_mut(&mut self, path: &str) -> Result<&mut Template, TmplError>
Get a mutable ref of a parsed tree in the group.
Sourcepub fn add_tmpl(&mut self, path: &str, tmpl_str: &str) -> Vec<ParseError>
pub fn add_tmpl(&mut self, path: &str, tmpl_str: &str) -> Vec<ParseError>
Add a template into the group.
Sourcepub fn remove_tmpl(&mut self, path: &str) -> bool
pub fn remove_tmpl(&mut self, path: &str) -> bool
Remove a template from the group.
This simply removes a template path. It is useful when doing hot-update debugging, but not suitable for final builds since it does not do cleanups. Returns true when a template is actually removed.
Sourcepub fn stringify_tmpl(&self, path: &str) -> Option<String>
pub fn stringify_tmpl(&self, path: &str) -> Option<String>
Regenerate a template content string of the specified template.
Sourcepub fn get_script(&mut self, path: &str) -> Result<&str, TmplError>
pub fn get_script(&mut self, path: &str) -> Result<&str, TmplError>
Get a script segment in the group.
Sourcepub fn add_script(&mut self, path: &str, content: &str)
pub fn add_script(&mut self, path: &str, content: &str)
Add a script segment into the group.
The content
must be valid JavaScript file content.
require
and exports
can be visited in this JavaScript segment, similar to Node.js.
Sourcepub fn remove_script(&mut self, path: &str) -> bool
pub fn remove_script(&mut self, path: &str) -> bool
Remove a script segment from the group.
This simply removes a script path. It is useful when doing hot-update debugging, but not suitable for final builds since it does not do cleanups. Returns true when a script is actually removed.
Sourcepub fn set_extra_runtime_script(&mut self, content: &str)
pub fn set_extra_runtime_script(&mut self, content: &str)
Set extra runtime JavaScript code as a string.
The content
must be valid JavaScript statements, ended by semicolon.
Sourcepub fn get_runtime_string(&self) -> String
pub fn get_runtime_string(&self) -> String
Output js runtime environment js code string.
Sourcepub fn get_runtime_var_list() -> Vec<&'static str>
pub fn get_runtime_var_list() -> Vec<&'static str>
Output js runtime environment js var name list.
Sourcepub fn direct_dependencies<'a>(
&'a self,
path: &str,
) -> Result<impl Iterator<Item = String> + 'a, TmplError>
pub fn direct_dependencies<'a>( &'a self, path: &str, ) -> Result<impl Iterator<Item = String> + 'a, TmplError>
Get direct dependency template files.
Sourcepub fn script_dependencies<'a>(
&'a self,
path: &str,
) -> Result<impl Iterator<Item = String> + 'a, TmplError>
pub fn script_dependencies<'a>( &'a self, path: &str, ) -> Result<impl Iterator<Item = String> + 'a, TmplError>
Get dependency script files.
Sourcepub fn inline_script_module_names<'a>(
&'a self,
path: &str,
) -> Result<impl Iterator<Item = &'a str>, TmplError>
pub fn inline_script_module_names<'a>( &'a self, path: &str, ) -> Result<impl Iterator<Item = &'a str>, TmplError>
Get inline script module names.
Sourcepub fn inline_script_start_line(
&self,
path: &str,
module_name: &str,
) -> Result<u32, TmplError>
pub fn inline_script_start_line( &self, path: &str, module_name: &str, ) -> Result<u32, TmplError>
Get the start line of the inline script.
Sourcepub fn inline_script_content(
&self,
path: &str,
module_name: &str,
) -> Result<&str, TmplError>
pub fn inline_script_content( &self, path: &str, module_name: &str, ) -> Result<&str, TmplError>
Get inline script content.
Sourcepub fn set_inline_script_content(
&mut self,
path: &str,
module_name: &str,
new_content: &str,
) -> Result<(), TmplError>
pub fn set_inline_script_content( &mut self, path: &str, module_name: &str, new_content: &str, ) -> Result<(), TmplError>
Set inline script content.
Sourcepub fn get_tmpl_gen_object(&self, path: &str) -> Result<String, TmplError>
pub fn get_tmpl_gen_object(&self, path: &str) -> Result<String, TmplError>
Convert to WXML GenObject js string.
Sourcepub fn get_tmpl_gen_object_groups(&self) -> Result<String, TmplError>
pub fn get_tmpl_gen_object_groups(&self) -> Result<String, TmplError>
Convert all to WXML GenObject js string.
Sourcepub fn get_wx_gen_object_groups(&self) -> Result<String, TmplError>
pub fn get_wx_gen_object_groups(&self) -> Result<String, TmplError>
Convert all to WXML GenObject js string, with wx environment support.
pub fn export_globals(&self) -> Result<String, TmplError>
pub fn export_all_scripts(&self) -> Result<String, TmplError>
Sourcepub fn contains_template(&self, path: &str) -> bool
pub fn contains_template(&self, path: &str) -> bool
Check if the group contains certain template.
Sourcepub fn list_template_trees(&self) -> impl Iterator<Item = (&str, &Template)>
pub fn list_template_trees(&self) -> impl Iterator<Item = (&str, &Template)>
List all available templates.