Trait dev_bestia_html_templating::HtmlTemplatingDataTrait [−][src]
pub trait HtmlTemplatingDataTrait {
fn data_model_name(&self) -> String;
fn replace_with_string(
&self,
placeholder: &str,
subtemplate_name: &str,
row_number: usize
) -> String;
fn replace_with_url(
&self,
placeholder: &str,
_subtemplate_name: &str,
_pos_cursor: usize
) -> UrlUtf8EncodedString { ... }
fn exists_next_node_or_attribute(&self, placeholder: &str) -> bool { ... }
fn replace_with_nodes(&self, placeholder: &str) -> Vec<Node> { ... }
fn process_sub_template(
&self,
template_name: &str,
_sub_templates: &Vec<SubTemplate>
) -> Vec<Node> { ... }
}
Expand description
the trait has only methods that can be implemented (overridden) It is not possible to define a method as “override forbidden” because the data model is always different and is known only to the project. if not implemented, the default functions below will be used.
Required methods
fn data_model_name(&self) -> String
fn data_model_name(&self) -> String
name of data model for debugging
Provided methods
fn replace_with_url(
&self,
placeholder: &str,
_subtemplate_name: &str,
_pos_cursor: usize
) -> UrlUtf8EncodedString
fn replace_with_url(
&self,
placeholder: &str,
_subtemplate_name: &str,
_pos_cursor: usize
) -> UrlUtf8EncodedString
same as replace_with_string, but return url exclusively for attributes value of href and src the url must be encoded in the beginning because it encodes segments of url prior to being composed together. use macro url_u!() to create an url, very like format! I try to avoid String here to force the developer to not forget to url_encode
fn exists_next_node_or_attribute(&self, placeholder: &str) -> bool
fn exists_next_node_or_attribute(&self, placeholder: &str) -> bool
boolean : is the next node existing or not: “wb_” or “sb_”
fn replace_with_nodes(&self, placeholder: &str) -> Vec<Node>
fn replace_with_nodes(&self, placeholder: &str) -> Vec<Node>
returns a vector of Nodes to replace the next Node
fn process_sub_template(
&self,
template_name: &str,
_sub_templates: &Vec<SubTemplate>
) -> Vec<Node>
fn process_sub_template(
&self,
template_name: &str,
_sub_templates: &Vec<SubTemplate>
) -> Vec<Node>
process sub-template