Struct handlebars_switch::SwitchHelper [] [src]

pub struct SwitchHelper;

Switch Helper

Provides the {{#switch}} helper to a Handlebars template.

Examples

use handlebars::Handlebars;
use handlebars_switch::SwitchHelper;

let mut handlebars = Handlebars::new();
handlebars.register_helper("switch", Box::new(SwitchHelper));

let tpl = "\
    {{#switch access}}\
        {{#case \"admin\"}}Admin{{/case}}\
        {{#default}}User{{/default}}\
    {{/switch}}\
";

assert_eq!(
    handlebars.template_render(tpl, &json!({"access": "admin"})).unwrap(),
    "Admin"
);

assert_eq!(
    handlebars.template_render(tpl, &json!({"access": "nobody"})).unwrap(),
    "User"
);

Trait Implementations

impl Clone for SwitchHelper
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl Copy for SwitchHelper
[src]

impl HelperDef for SwitchHelper
[src]

[src]

[src]

Auto Trait Implementations

impl Send for SwitchHelper

impl Sync for SwitchHelper