mustache / spec

The Mustache spec.
MIT License
364 stars 71 forks source link

Idea: named html chunks #59

Closed devinrhode2 closed 11 years ago

devinrhode2 commented 11 years ago

Taking a little inspiration from DerbyJS here.

In derby, and in the multiplex of other templating solutions, you can abstract a chunk of html and use it in various places. Same concept as functions for chunks of code. In derby, it looks like:

<ui:modal>
  <div class="...
  </div>

//Use the modal:
...
  <ui:modal />

Perhaps in mustache this could be like:

{{ *widgetName }}
  <div>widget code</div>
{{/}}

//Using it:
...
  {{ **widgetName }}

Haven't put any thought into the potential syntax of it yet, but what do you guys think? @groue

groue commented 11 years ago

Hi Devin !

Is it something like partials, but defined right in the template ?

devinrhode2 commented 11 years ago

wait... wow, this is the exact concept of partials. Closing.

groue commented 11 years ago

Glad to hear from you anyway :-)

spudly commented 11 years ago

What's wrong with partials defined within the template? I would LOVE this feature. This should be reopened! Partials are great, but it'd sure be nice to be able to define partials right inside the template that uses them. In most cases, the partials I create are only used by one parent template so it's a lot of extra work to create the partial the way it works right now. Also, a lot of my partials are one-liners. As a result, I often times end up just copy/pasting instead.

devinrhode2 commented 11 years ago

actually we should just re-open a clean thread specifically for defining partials inline, care to do the favors @spudly?

spudly commented 11 years ago

See issue #63.