librelist archives

« back to archive

Flask & SHPAML

Flask & SHPAML

From:
Alasdair Macmillan
Date:
2010-08-11 @ 13:04
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

Re: Flask & SHPAML

From:
Pitmairen
Date:
2010-08-13 @ 15:16
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.

Re: [flask] Flask & SHPAML

From:
JimG
Date:
2010-08-11 @ 13:37
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
>

Re: [flask] Flask & SHPAML

From:
Alasdair Macmillan
Date:
2010-08-11 @ 13:55
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
> 

Re: [flask] Flask & SHPAML

From:
JimG
Date:
2010-08-11 @ 15:13
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
>>
>
>
>

Re: [flask] Flask & SHPAML

From:
Alasdair Macmillan
Date:
2010-08-11 @ 18:50
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
>> 
> 
> 

Re: [flask] Flask & SHPAML

From:
Dag Odenhall
Date:
2010-08-11 @ 19:25
> 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.

Re: [flask] Flask & SHPAML

From:
JimG
Date:
2010-08-12 @ 10:56
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.
>
>

Re: [flask] Flask & SHPAML

From:
Dag Odenhall
Date:
2010-08-12 @ 16:53
> 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.
>         
> 
>