Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Hugo Peixoto
@hugopeixoto
probably
Łukasz Strzebińczyk
@lstrzebinczyk
ah, I see
ok, thanks
Łukasz Strzebińczyk
@lstrzebinczyk

I took some time to implement mustache rendering engine as I saw fit. It does not use any metaprogramming at all, any complex template analisis, and I believe the code is much simpler and easier to follow. I cover all features mentioned at http://mustache.github.io/mustache.5.html except

  • lambdas, because I don't see the point of that
  • setting delimeter, again because I don't see the point of that
  • partials, because their implementation will depend on your answer to this message.

Everything else is probably covered and is from 15 to 30 times faster than current mustache/mustache repository.
For now it covers the

Beard.render(template, data)

API, where data is a hash or Beard::View object.

You can find the benchmarks at https://github.com/KillaPL/beard_vs_mustache and run them yourselves.
You can find the code at https://github.com/KillaPL/beard.

I would be happy if you guys could take a look and let me know if you'd be interested in merging this solution into canonical mustache (after it's polished and prepared, of course).

Łukasz Strzebińczyk
@lstrzebinczyk
I now see that I sort of misunderstood lambdas, I can of course implement this
Łukasz Strzebińczyk
@lstrzebinczyk
I added context lookup, I noticed it was missing. Still 12.7 to 30 times faster : )
Justin Hileman
@bobthecow
@KillaPL Nice! How's it do against the spec?
Łukasz Strzebińczyk
@lstrzebinczyk
So far I support everything except lambdas, partials and delimeter setting
I will probably add lambdas and delimeter setting tomorrow
and partials when Beard's future is decided, either integrate with Mustache or write something simple from scratch
Łukasz Strzebińczyk
@lstrzebinczyk
Ah, sorry, I also don't support setting unescaped values with {{&
but that is, like, a 15 minutes of work
Hugo Peixoto
@hugopeixoto
you should probably integrate the spec tests into your repository
Ricardo Mendes
@locks
@KillaPL hey, I'm been thinking about KillaPL/beard and while I appreciate your contributions I think you'd do best developing it independently
and then when it passes the spec you can add it to the list of available implementations
it's just too big a change and I think there's some value in a clean room implementation alternative
Łukasz Strzebińczyk
@lstrzebinczyk
Hi. This was one of the ideas I came up with. I have some more work to do with my day job and Beard is standing in place, It will have to wait some time.
I also might have some comments to the spec itself, the spec tests seem to assume the implementation take care of whitespace
but I have to make more of that work first
Ricardo Mendes
@locks
yes, there are some whitespace-related specs
Justin Hileman
@bobthecow
Mostly around “standalone lines”, basically what happens when a line only includes whitespace and a tag that’s not interpolated.
And indenting partials.
Mike Henriquez
@mikehenriquezf
hello guys, how can i make something like this, if i have the data display in <li>?? http://i.imgur.com/hvr38uV.jpg
Justin Hileman
@bobthecow
Can you give us more context?
Mike Henriquez
@mikehenriquezf
i have an array with 10 articles, i want to display them but in the middle of the list i want to display a 300x250 ad
5 articles, Ad, 5 more articles
Justin Hileman
@bobthecow
@mikehenriquezf Is it always 5 / ad / 5?
split your articles list in half (in code, before it goes to the template). Then do {{# first_set }}{{> article }}{{/ first_set }} {{> ad }} {{# second_set }}{{ > article }}{{/ second_set }}
Jakob Damgaard Møller
@jakobdo
Can i get this output with mustachejs: https://dpaste.de/itfU ?
Justin Hileman
@bobthecow
You'll need to prepare your data first.
Jakob Damgaard Møller
@jakobdo
So Mustache cant do the "ifchanged" thing?
Justin Hileman
@bobthecow
nope, because that’s logic, and mustache doesn’t logic ;)
Jakob Damgaard Møller
@jakobdo
Thanks.
Frank Pinto
@frankpinto
hello all!
Trying to get rails to use mustache as the templating engine when it generates scaffolds, etc., anybody know how?
google gave me a couple leads but if anybody here's done it before, I'd appreciate the help :)
Ricardo Mendes
@locks
hey @frankpinto, I'm not sure you can?
Richard Doe
@rwd
Is there any way to use Rails fragment caching with Mustache?
Leonardo "Alemax" Fonseca Ferreira
@leonardoalemax
hello guys, i`m trying to render a template like this:
```<div id="{{renderwithmustach}}" ng-click="{{letangularrender}}" > ````
how to not render the angular tag?
just the mustach one?
Justin Hileman
@bobthecow
@leualemax mustache lets you change delimiters to one that doesn't conflict:
{{=<% %>=}}
<div id="<% renderwithmustache %>" ng-click="{{ letangularrender }}">
John Arnold
@Surreal9
Does anyone know why trying to render a variable that contains a url, it hides the "http:" part and only shows "//restoftheurl.com"? even when using triple braces to cancel escaping? ie {{{myUrl}}}
Ricardo Mendes
@locks
@Surreal9 that's the first I've heard of
Selwyn
@Siilwyn
Does anybody know if a npm package exists that let's me pass a partial, views (and data) directory to it and in turn outputs html to a given directory?
Ricardo Mendes
@locks
@Siilwyn I don't think so
I suggest a bash script to feed the necessary files to the mustache binary
Selwyn
@Siilwyn
@locks :smile: never expected an answer
hmm that doesn't sound ideal since I'm using npm scripts. Would that be a long bash script?