fhd / clostache

{{ mustache }} for Clojure
GNU Lesser General Public License v3.0
318 stars 62 forks source link

Support non-clostache partials #29

Open JulianBirch opened 11 years ago

JulianBirch commented 11 years ago

I'll happily write this and send a pull request. At the moment, my plan is to

  1. allow you to specify a string as a partial, in which case it is interpreted as a clostache template
  2. allow you to specify a function, in which case it is invoked and assumed to return HTML.

My principal reason for wanting to do this is to handle small nasty pieces of code where hiccup is a better fit, but you could use it to mix and match template engines as well.

JulianBirch commented 11 years ago

Looking at the code, this is hard. Doesn't mean it isn't worth doing, but it's hard to achieve directly.

fhd commented 11 years ago

I don't fully understand this, partials are already passed as strings. Could you give an example of what you mean?

JulianBirch commented 11 years ago

Actually, part 1 is "support existing functionality", part 2 is new. So you could send in a partials like this.

    { :x "Standard Clostache Partial"
      :y partial-thats-actually-a-function }

Applying this to the current code base is hard, though. But if I ever do decide to try to code compilable templates, I think it would be worth trying to separate out expression evaluation and partial evaluation.

fhd commented 11 years ago

Yeah, that'd make sense.

fhd commented 11 years ago

Then again, wouldn't a lambda do?