Mu icon indicating copy to clipboard operation
Mu copied to clipboard

Get Templates

Open martinpfeiffer opened this issue 12 years ago • 1 comments

Hey,

Is there a way to just get the template informations mu2 uses? Just resolve the partials and don't render any data to the template (and don't replace other mustache tags except partials)

Use case: Use the same templates on client and server. I have to find a way to deliver a partial free version of the templates to the client.

martinpfeiffer avatar Oct 04 '13 09:10 martinpfeiffer

Because partials can be recursive, you cannot expand the partial tags at compile time in Mustache. What Mu does is compile all the needed partials at compile time and references them in the cache during render time.

An simple example of a recursive template:

// person.html

<ul>
  {{#friends}}
    <li>
      {{>person.html}}
    </li>
  {{/friends}}
</ul>

Most client side Mustaches have a form of partials as well, I would try to figure out a way to send those down apart from the main template. Would having an easily accessible list of partial files that a template references be helpful? Something like: mu.whichPartials(compiledTemplateOrPath); // => ["foo.html", "bar.html"]

raycmorgan avatar Oct 04 '13 17:10 raycmorgan