Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mustache render on the server (rails) and on the client (javascript)

Is there any documentation on Mustache best practices when using on the server (with rails) and on the client (with javascript)?

# hello_world.mustache
Hello {{planet}}

# some other file
<%
hello_world_template = File.read(File.dirname(__FILE__) + "/hello_world.mustache")
%>

<script id="hello_world_template" type="text/x-jquery-tmpl"> 
    <%= hello_world_template %>
</script>

<script>
    // $.mustache = using mustache.js and a jquery mustache wrapper 
    // search on "Shameless port of a shameless port"
    document.write($.mustache($("#hello_world_template").html(), { "planet" : "World!" }));
</script>

<%= Mustache.render(hello_world_template, :planet => "World!") %>

The above isn't scalable. I'd prefer not to make my own engine for this.

Is there a more complete templating engine that allows reuse of templates on the server and on the client?

Additionally, one that accounts for nested templates on the server and the client?

like image 399
Mark Peterson Avatar asked Feb 23 '23 07:02

Mark Peterson


1 Answers

There is Poirot available: Mustache + Rails 3.

like image 120
apneadiving Avatar answered Mar 16 '23 00:03

apneadiving