Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make bbmustache work with Elixir?

I'm trying to use the bbmustache package with Elixir. Adapting the documentation from Erlang to Elixir I tried multiple calls but none seems to be working.

:bbmustache.render("name: {{name}}", %{"name" => "hoge"})
# => "name: "

:bbmustache.render("name: {{name}}", %{name: "hoge"})
# => "name: "

:bbmustache.render("name: {{name}}", [{:name, "hoge"}])
# => "name: "

:bbmustache.render("name: {{name}}", [{"name", "hoge"}])
# => "name: "

There is probably something I don't get yet about strings and binaries or something else.

If anyone knows how to make it work that'd be awesome :-)

Thanks!

like image 847
Happynoff Avatar asked Feb 20 '26 05:02

Happynoff


1 Answers

bbmustache seems to require the key of the Map or List of tuples to be char lists. This works:

iex(1)> :bbmustache.render("name: {{name}}", %{'name' => "hoge"})
"name: hoge"

Also render/3 you could pass the type of the keys.

iex(1)> :bbmustache.render("name: {{name}}", %{"name" => "hoge"}, [key_type: :binary])
"name: hoge"
like image 121
Dogbert Avatar answered Feb 23 '26 18:02

Dogbert



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!