Pitmairen / hamlish-jinja

A haml-ish syntax for jinja2 templates
BSD 3-Clause "New" or "Revised" License
131 stars 11 forks source link

How to use hamlish-jinja in pylons #1

Closed freewind closed 14 years ago

freewind commented 14 years ago

Hi, pitmairen: I'm new to python, and learning pylons with jinja2. I want to use hamlish-jinja, but found it not works. (The templates are rendered as plain text). I have googled, but found nothing useful. I need you help.

My configuration of "pylons/mysite/config/enviroment.py" is:

# Hasmlish-jinja
from jinja2 import Environment, PackageLoader
from hamlish_jinja import HamlishExtension

config['pylons.app_globals'].jinja2_env = Environment(
    loader=PackageLoader('mysite', 'templates'),
extensions=[HamlishExtension]
)

My controller is: hello.py

from pylons.templating import render_jinja2
class HelloController(BaseController):
    def index(self):
       return render_jinja2('/hello.haml')

And my template is: mysite/templates/hello.haml

.main << Hello

Then I start the server, and visit: http://localhost:5000/hello/index

It shows a page with plain text: .main << Hello

What should I do now? Is there anything I was missing? Thank you in advance!

freewind commented 14 years ago

I just found it works, but the result is not what I expected. After reading the readme again, I found that "hamlish-jinja" can't convert .main to <div class="main" />`. This IS the most important thing and advantage of HAML, I can't believe that you missed it.

Pitmairen commented 14 years ago

I know about that shortcut, but i don't like it so i didn't implement it. But it should be pretty easy to add though, so maybe i will add it.

freewind commented 14 years ago

That would be great, and thank you! It's very useful and convenient to use them use SASS to design the layout, I love haml just because of that.

Pitmairen commented 14 years ago

I have added this syntax now. :)

freewind commented 14 years ago

I'm tring it in my website now, and most works well, thank you! And, may I have some suggestions?