Pitmairen/hamlish-jinja

Are you interested in a HAML to Hamlish convertor?

Opened this issue · 5 comments

mdda commented

I hacked something together so that I could take output from html2haml, and make it into a hamlish-jinja template.

If this is something that's potentially interesting, I can fork this module, add a utilities folder, and issue a pull request... Or I could just email you the file. (the coding is nothing that I'm proud of, btw).

Martin
:-)

sjz commented

I'm interested in your utilities setup stuff..

I have a potential extension for some mustache generating shortcuts
Templating of templates sounds dumb, but I've somehow found a use for it :)
I was thinking it could just be enabled similarly to enable_div_shortcuts

Pitmairen: are you interested in mine also?

@mdda:
Cool, it could be usefull, just fork and make a pull request.

@sjz:
Can you post an example of how the syntax will look like?

sjz commented

At the moment, it's implemented as a pre-processor to your pre processor (....).
This was to future-proof myself against any updates you make as we both won't need to maintain the common code base.
Basically, it spams -raw {{mustachestuff}} which is then rendered nicely

Lines starting with + are mustache lines, but this can be changed to whatever is deemed most suitable
Still not working awesomely - as I develop it further I'll take into account any suggestions etc too

This:

+#some_section
  .container
    +some_variable_name
    +{some_escaped_variable
    +>a_partial
    +^inverted_section
    +!comment stuff goes here

Produces:

{% raw %}{{#some_section}}{% endraw %}
<div class="container">
    {% raw %}{{some_variable_name}}{% endraw %}
    {% raw %}{{{some_escaped_variable}}}{% endraw %}
    {% raw %}{{>a_partial}}{% endraw %}
    {% raw %}{{^inverted_section}}{% endraw %}
    {% raw %}{{/inverted_section}}{% endraw %}
    {% raw %}{{!comment stuff goes here}}{% endraw %}
</div>
{% raw %}{{/some_section}}{% endraw %}

Which is really:

{{#some_section}}    
<div class="container">
{{some_variable_name}}    
{{{some_escaped_variable}}}    
{{>a_partial}}    
{{^inverted_section}}    
{{/inverted_section}}    
{{!comment stuff goes here}}
</div>
{{/some_section}}

I think it probably better to have this in a separate library. To use this i guess you will need a separate library anyway, like pystache to process the output.

And since you are generating mustache templates you are probably not using any jinja logic (if, for..), maybe its better to make a preprocessor for someting like SHPAML, which as far as i know don't have logic.

sjz commented

Definitely still using jinja logic-or I would have created hamlish-stache :P
My example didn't really illustrate this though..
The idea is to use mustache.js, with pystache as a fallback
Youre right, as it can remain as one, I'll leave it as a separate library
Thanks for the cool tool btw