Struct TmplGroup

Source
pub struct TmplGroup { /* private fields */ }
Expand description

A template group in which the templates can ref each other.

Implementations§

Source§

impl TmplGroup

Source

pub fn new() -> Self

Create a new template group.

Source

pub fn new_dev() -> Self

Create a new template group in dev mode.

Source

pub fn dev(&self) -> bool

Get the dev mode.

Source

pub fn import_group(&mut self, group: &TmplGroup)

import another group.

Source

pub fn get_tree(&self, path: &str) -> Result<&Template, TmplError>

Add a ref of a parsed tree in the group.

Source

pub fn get_tree_mut(&mut self, path: &str) -> Result<&mut Template, TmplError>

Get a mutable ref of a parsed tree in the group.

Source

pub fn add_tmpl(&mut self, path: &str, tmpl_str: &str) -> Vec<ParseError>

Add a template into the group.

Source

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.

Source

pub fn stringify_tmpl(&self, path: &str) -> Option<String>

Regenerate a template content string of the specified template.

Source

pub fn get_script(&mut self, path: &str) -> Result<&str, TmplError>

Get a script segment in the group.

Source

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.

Source

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.

Source

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.

Source

pub fn get_runtime_string(&self) -> String

Output js runtime environment js code string.

Source

pub fn get_runtime_var_list() -> Vec<&'static str>

Output js runtime environment js var name list.

Source

pub fn direct_dependencies<'a>( &'a self, path: &str, ) -> Result<impl Iterator<Item = String> + 'a, TmplError>

Get direct dependency template files.

Source

pub fn script_dependencies<'a>( &'a self, path: &str, ) -> Result<impl Iterator<Item = String> + 'a, TmplError>

Get dependency script files.

Source

pub fn inline_script_module_names<'a>( &'a self, path: &str, ) -> Result<impl Iterator<Item = &'a str>, TmplError>

Get inline script module names.

Source

pub fn inline_script_start_line( &self, path: &str, module_name: &str, ) -> Result<u32, TmplError>

Get the start line of the inline script.

Source

pub fn inline_script_content( &self, path: &str, module_name: &str, ) -> Result<&str, TmplError>

Get inline script content.

Source

pub fn set_inline_script_content( &mut self, path: &str, module_name: &str, new_content: &str, ) -> Result<(), TmplError>

Set inline script content.

Source

pub fn get_tmpl_gen_object(&self, path: &str) -> Result<String, TmplError>

Convert to WXML GenObject js string.

Source

pub fn get_tmpl_gen_object_groups(&self) -> Result<String, TmplError>

Convert all to WXML GenObject js string.

Source

pub fn get_wx_gen_object_groups(&self) -> Result<String, TmplError>

Convert all to WXML GenObject js string, with wx environment support.

Source

pub fn export_globals(&self) -> Result<String, TmplError>

Source

pub fn export_all_scripts(&self) -> Result<String, TmplError>

Source

pub fn len(&self) -> usize

Returns the number of templates in the group.

Source

pub fn contains_template(&self, path: &str) -> bool

Check if the group contains certain template.

Source

pub fn list_template_trees(&self) -> impl Iterator<Item = (&str, &Template)>

List all available templates.

Trait Implementations§

Source§

impl Debug for TmplGroup

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> ErasedDestructor for T
where T: 'static,