clostache icon indicating copy to clipboard operation
clostache copied to clipboard

Support non-clostache partials

Open JulianBirch opened this issue 11 years ago • 5 comments

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 avatar Apr 26 '13 16:04 JulianBirch

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

JulianBirch avatar Apr 28 '13 09:04 JulianBirch

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

fhd avatar May 13 '13 05:05 fhd

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.

JulianBirch avatar May 13 '13 19:05 JulianBirch

Yeah, that'd make sense.

fhd avatar Jun 05 '13 12:06 fhd

Then again, wouldn't a lambda do?

fhd avatar Jun 05 '13 12:06 fhd