#fluent #bracket #template

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

#368 in Template engine

Download history 2/week @ 2023-11-08 2/week @ 2023-11-15 22/week @ 2023-11-22 35/week @ 2023-11-29 11/week @ 2023-12-06 11/week @ 2023-12-13 11/week @ 2023-12-20 12/week @ 2023-12-27 11/week @ 2024-01-03 1/week @ 2024-01-10 19/week @ 2024-01-17 22/week @ 2024-01-24 22/week @ 2024-01-31 1/week @ 2024-02-07 95/week @ 2024-02-14 397/week @ 2024-02-21

537 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
~167K SLoC