TIP: Use Markdown or, <pre> for multi line code blocks / <code> for inline code.
These forums are read-only and for archival purposes only!
Please join our new forums at discourse.kohanaframework.org
Kostache/Mustache Spacing Problem
  • I don't know if the culprit is kostache or mustache, or myself?!

    I lose my space if I put it just after a tag.

    <li{{#active}} class="active"{{/active}}>
    // fails (space is gone)
    <liclass="active">


    If the space is not directly after the tag it works.

    <l{{#active}}i class="active">{{/active}}{{^active}}i>{{/active}}
    // works (but is really ugly)
    <li class="active">
  • Instead of splitting it in the middle of the tag, you could just do the whole tag twice. It is still extra code, but it would be a little more legible.

    {{#active}}<li class="active">{{/active}}
    {{^active}}<li>{{/active}}
  • @zombor - Ok sorry, should have check mustache issues first.

    @slacker - Yes, of course a much better alternative. Why didn't I think of that?
  • You can also do it like this:
    <li {{#active}}class="active"{{/active}}>
    You'll end up with a space in the tag when no class is specified, but I don't think it's much of an issue.
  • Why don't you just do

    <li class="{{active}}">bla bla</li>


    and then in your view class

    return $active ? 'active' : '';


  • @loonies - I guess I could do that, but I don't really like the idea of polluting my HTML output with:

    <li class="">
  • Ahhh hopefully these issues can be ironed out of Mustache.php ASAP. Until then I think pollution in one form or another is a necessary evil.
  • Unfortunately fixing this problem seems non-trivial. I think its a regex problem, but not obvious to fix. The ruby version gets it right though.
  • Lets move to ruby. ^__^

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion