#fluent #brackets #integration #loader #helper #language

bracket-fluent

Fluent integration for the bracket template engine

11 releases (4 breaking)

0.5.3 Jul 14, 2021
0.5.2 Nov 26, 2020
0.4.0 Nov 24, 2020
0.3.2 Nov 23, 2020
0.1.0 Nov 16, 2020

#439 in Template engine

Download history 25/week @ 2024-02-25 1/week @ 2024-03-03 108/week @ 2024-03-31

108 downloads per month

MIT/Apache

10KB
123 lines

Bracket Fluent

Helper for the bracket template engine that integrates with project fluent using the loaders provided by fluent templates.

Examples

Using either a static or arc loader should yield the same result:

cargo run --example=static
cargo run --example=arc

lib.rs:

Helper for fluent language lookup.

The root data for the template must contain a lang field with the identifier of the current language.

Assuming a fluent language file in locales/en/main.ftl and the lang field is set to en, using the contents:

welcome = Hello!
greeting = Hello { $name }!
block = { $var1 } { $var2 }

We can resolve the message in a template using the fluent helper like this:

{{fluent "welcome"}}

Pass variables using the helper hash parameters:

{{fluent "greeting" name="world"}}

If you need to pass multi-line variables to a message use the fluentparam syntax inside a block call:

{{#fluent "block"~}}
{{#fluentparam "var1"~}}
This is some multi-line content for 
the first variable parameter named var1.
{{/fluentparam}}

{{#fluentparam "var2"}}
Which is continued in another multi-line 
paragraph using the variable named var2.
{{~/fluentparam~}}
{{/fluent}}

Dependencies

~11MB
~181K SLoC