Hi I am quite keen on HAML-esque HTML pre-processing and I've been looking around the Python world to see if there is something similar. The closest I can find the is still in development is SHPAML. I'm looking for pointers in to how to use with Flask? Kind thanks Alasdair
I have created an extension for jinja that adds haml-ish syntax to your templates. You can find it here: http://github.com/Pitmairen/hamlish-jinja I haven't tested it much and the code is a little ugly but it should work, i think.
This sounds like an interesting thing, although I guess the question is how HAML would interact with Jinja2? Thanks, Jim. On 11 August 2010 14:04, Alasdair Macmillan <al@atomised.coop> wrote: > Hi > > I am quite keen on HAML-esque HTML pre-processing and I've been looking > around the Python world to see if there is something similar. The closest I > can find the is still in development is SHPAML. I'm looking for pointers in > to how to use with Flask? > > Kind thanks > Alasdair >
http://github.com/p/shpaml-jinja I found this on a google search? On 11 Aug 2010, at 14:37, JimG wrote: > This sounds like an interesting thing, although I guess the question is how HAML would interact with Jinja2? > > Thanks, Jim. > > On 11 August 2010 14:04, Alasdair Macmillan <al@atomised.coop> wrote: > Hi > > I am quite keen on HAML-esque HTML pre-processing and I've been looking around the Python world to see if there is something similar. The closest I can find the is still in development is SHPAML. I'm looking for pointers in to how to use with Flask? > > Kind thanks > Alasdair >
Given SHPAML (awful name) is a pre-processor can't you just use it to generate your Jinja2 templates which you then use in flask? No integration necessary? Cheers, Jim. On 11 August 2010 14:55, Alasdair Macmillan <al@atomised.coop> wrote: > http://github.com/p/shpaml-jinja > > I found this on a google search? > > On 11 Aug 2010, at 14:37, JimG wrote: > > This sounds like an interesting thing, although I guess the question is how > HAML would interact with Jinja2? > > Thanks, Jim. > > On 11 August 2010 14:04, Alasdair Macmillan <al@atomised.coop> wrote: > >> Hi >> >> I am quite keen on HAML-esque HTML pre-processing and I've been looking >> around the Python world to see if there is something similar. The closest I >> can find the is still in development is SHPAML. I'm looking for pointers in >> to how to use with Flask? >> >> Kind thanks >> Alasdair >> > > >
I guess I could Jim if I knew how. Extreme programming beginner here. I guess ideally I would like something like HAML, GHRML, SHPAML baked into Flask as an extension option but I don't know how to do it. Frustated beginner! On 11 Aug 2010, at 16:13, JimG wrote: > Given SHPAML (awful name) is a pre-processor can't you just use it to generate your Jinja2 templates which you then use in flask? > > No integration necessary? > > Cheers, Jim. > > On 11 August 2010 14:55, Alasdair Macmillan <al@atomised.coop> wrote: > http://github.com/p/shpaml-jinja > > I found this on a google search? > > On 11 Aug 2010, at 14:37, JimG wrote: > >> This sounds like an interesting thing, although I guess the question is how HAML would interact with Jinja2? >> >> Thanks, Jim. >> >> On 11 August 2010 14:04, Alasdair Macmillan <al@atomised.coop> wrote: >> Hi >> >> I am quite keen on HAML-esque HTML pre-processing and I've been looking around the Python world to see if there is something similar. The closest I can find the is still in development is SHPAML. I'm looking for pointers in to how to use with Flask? >> >> Kind thanks >> Alasdair >> > >
> I guess I could Jim if I knew how. Extreme programming beginner here. > I guess ideally I would like something like HAML, GHRML, SHPAML baked > into Flask as an extension option but I don't know how to do it. from flask import render_template_string from shpaml import convert_text def render_template(template_name, **context): with app.open_resource('templates/' + template_name) as f: return render_template_string(convert_text(f.read()), **context) Lacks support for module templates, but it's a start.
Generally there seem to be a variety of these type of tools. HAML, SHPAML. Pamela, Creole, Markdown. In each case someone has come up with a more succinct syntax which can be transformed into HTML. My two instincts are: 1. The conversion from >whatever< to HTML should not happen per request, or even per instantiation of the application if its not subject to change. Therefore running as a preprocessor makes some sense to me rather than building it into a Framework like Flask. 2. However when in development it would be nice not to have to run a preprocessor everytime one makes a change to a template. Given that I'm puzzled where the correct integration point might be, or even if there should be an integration. Thanks, Jim. On 11 August 2010 20:25, Dag Odenhall <dag.odenhall@gmail.com> wrote: > > I guess I could Jim if I knew how. Extreme programming beginner here. > > I guess ideally I would like something like HAML, GHRML, SHPAML baked > > into Flask as an extension option but I don't know how to do it. > > from flask import render_template_string > from shpaml import convert_text > > def render_template(template_name, **context): > with app.open_resource('templates/' + template_name) as f: > return render_template_string(convert_text(f.read()), **context) > > Lacks support for module templates, but it's a start. > >
> Generally there seem to be a variety of these type of tools. HAML, > SHPAML. Pamela, Creole, Markdown. > > > In each case someone has come up with a more succinct syntax which can > be transformed into HTML. > > > My two instincts are: > > > 1. The conversion from >whatever< to HTML should not happen per > request, or even per instantiation of the application if its not > subject to change. Therefore running as a preprocessor makes some > sense to me rather than building it into a Framework like Flask. > > > 2. However when in development it would be nice not to have to run a > preprocessor everytime one makes a change to a template. > > > Given that I'm puzzled where the correct integration point might be, > or even if there should be an integration. > Yes, I don't recommend my code in heavy production sites. Just something to get started experimenting. Compatibility with flask.render_template means easy swapping between the two. > > Thanks, Jim. > > On 11 August 2010 20:25, Dag Odenhall <dag.odenhall@gmail.com> wrote: > > I guess I could Jim if I knew how. Extreme programming > beginner here. > > I guess ideally I would like something like HAML, GHRML, > SHPAML baked > > into Flask as an extension option but I don't know how to do > it. > > > from flask import render_template_string > from shpaml import convert_text > > def render_template(template_name, **context): > with app.open_resource('templates/' + template_name) as f: > return render_template_string(convert_text(f.read()), > **context) > > Lacks support for module templates, but it's a start. > > >