News for hackers. Stuff that matters.
Re:Introducing Nemo: A Pythonic Haml by Kilimanjaro on Thursday January 06, 2011 @03:26PM (#2077001)
I like what I see and of course I had to optimize it for my very peculiar taste:

    html
    head
      title My web page
      meta name=this content=that
      link rel=stylesheet href=style.css
      script src=jquery.js
    body
      header
        logo
          img src=logo.jpg
      main
        content .center
          h1 Welcome to my site
          p
            This is my first post
            Feel free to comment at the end.
    
          pre #hello
            a=1+2+3
            print a
    
      footer
        p no copyrights at all

Assume every first word is a known tag or convert it to div with id. Use significant white space. Content tags like 'p' or 'pre' are closed by a blank line.

It may work for 90% of my own projects and it is by far the simplest markup I have seen, evar.

Re:Introducing Nemo: A Pythonic Haml by true_religion on Thursday January 06, 2011 @03:40PM (#2077058)
Did you fork it on Github?

I'd love to see your code.

Right now, its' looking like a better version of SPHaml, but who can tell without seeing the gotchas'.

Like when it comes to assumptions, you'd be surprised how many times I write the word "option" as the first thing in a sentence. =)

Re:Introducing Nemo: A Pythonic Haml by Kilimanjaro on Thursday January 06, 2011 @03:48PM (#2077090)
No no that's just a quick brain dump just to see if it could be optimized a bit further. I love simplicity and always try to simplify stuff just for the fun of it.
Re:Introducing Nemo: A Pythonic Haml by true_religion on Thursday January 06, 2011 @05:14PM (#2077516)
Got it.

If you do get the time, check out the code and see if you can tweak things to your liking.

I'll be doing a cleanup/refactoring later this week to make things better.

However, the core of Nemos' parsing is handled by pyparsing, so if you can read and write eBNF, then you can tweak Nemos' syntax to your liking pretty easily.

Re:Introducing Nemo: A Pythonic Haml by true_religion on Thursday January 06, 2011 @01:15PM (#2076422)
I should probably mention. Nemo is built on top of Mako, so there's a tiny speed bump for Nemo processing then its as fast as Mako once the templates are compiled and cached.

Mako is faster than Django templates--at least by a factor of 4--and in the neighborhood of speed with Cheetah. Only Spitfire templates are faster.

This is important for any app that is CPU bound due to rendering speed.

Re:Introducing Nemo: A Pythonic Haml by oofoe on Thursday January 06, 2011 @03:30PM (#2077012)
A while back, I wrote a very small Python HTML rendering library that gives some of the benefits of this notation while still being Python source code. You _may_ find it interesting if this is the sort of thing you find interesting...

http://hotwax.cjmunday.com/python.html#sec-1.2

See the CherryPy file browser example later in the page for a demonstration of how it's used.

Re:Introducing Nemo: A Pythonic Haml by true_religion on Thursday January 06, 2011 @03:38PM (#2077051)
Oh definitely.

To me, it seems that everyone is striving to find an easier way to programmatically create HTML in Python. The current range of templating languages just don't cut it.

I think there's no definitive solution partially because everyone is copying Haml, and Hamls' syntax and trade-offs aren't really appropriate for Python users.

Re:Introducing Nemo: A Pythonic Haml by dmclain on Thursday January 06, 2011 @02:17PM (#2076707)
I've been contributing to another HAML derivitive for python called HamlPy (https://github.com/jessemiller/HamlPy). It compiles down to Django templates, which made it very easy for me to convert my existing project. It's under pretty active development right now.
Re:Introducing Nemo: A Pythonic Haml by raineri on Thursday January 06, 2011 @02:31PM (#2076775)
I forked that project and made it compile down to a Mako template (I use pylons). https://github.com/raineri/MakoHaml :)
Re:Introducing Nemo: A Pythonic Haml by true_religion on Thursday January 06, 2011 @02:58PM (#2076888)
You might want to update your readme file so everyone knows that it compiles down to Mako just at a glance.

Right now its confusing.

But if I'd known about this project a few days ago, you'd have definitely been added to my list of Muses.

Also, does your fork support the full range of Mako control structures? Looking at the nodes.py it seems that its still targeted towards a Django-templates backend.

Re:Introducing Nemo: A Pythonic Haml by raineri on Thursday January 06, 2011 @03:13PM (#2076949)
Yeah, I quickly hacked it together, I will update the readme soon. It does support the mako control structures. You see them rendered around line 200 in nodes.py.
Re:Introducing Nemo: A Pythonic Haml by true_religion on Thursday January 06, 2011 @03:35PM (#2077038)
You forgot to change the list of self-closing tags.

I'd suggest making 'while' self closing.

How do you handle Mako defs, and namespace tags?

Re:Introducing Nemo: A Pythonic Haml by true_religion on Thursday January 06, 2011 @03:14PM (#2076956)
You can actually use Nemo alongside Django-templates.

It registers a Mako template loader with Django, that by default points to your /templates directory in your folder.

However you can override it by modifying MAKO_TEMPLATE_DIRS in your settings.py. MAKO_TEMPLATE_DIRS is just a tuple containing the directories to look under for Mako/Nemo files.

My full project runs under Mako, but 3rd party apps, and the django admin run with django-templates.

Re:Introducing Nemo: A Pythonic Haml by allenp on Thursday January 06, 2011 @02:11PM (#2076686)
"Mixed content documents, and more rope than you know what to do with. That's Nemo."

Hilarious. And probably true.

Re:Introducing Nemo: A Pythonic Haml by gawker on Thursday January 06, 2011 @01:52PM (#2076609)
Love it! And will definitely use it. I was looking at using Haml to build my sites alongside Django but I'll give this a try!
Re:Introducing Nemo: A Pythonic Haml by piranha on Thursday January 06, 2011 @02:42PM (#2076828)
Re:Introducing Nemo: A Pythonic Haml by true_religion on Thursday January 06, 2011 @03:31PM (#2077019)
Ah I forgot about Mint.

I don't want to talk badly about it--because to be honest it has some really cool features like chained-method-calls that allow you to quickly compose HTML attributes via inheritance----but Mint has always struck me as more Perl than Python.

Look at this:

    @p.class(title).title({{ doc.title }}) {{ doc.title }}
That transforms into this HTML (unescaped urls because Mint produces XML by default):

    <p class="title" title="&gt;b&lt;title&gt;/b&lt;">
        <b>title</b>
    </p>
The alternative in Nemo is:

    % p .'title' title='${doc.title}'   ||   ${ doc.title }
I don't know why Nemo looks better in my eyes but I think it has to do with explicit separation, and string substitution instead of a method-call syntax.

Mint feels like a programming language that happens to produce HTML as a side-effect.

Re:Introducing Nemo: A Pythonic Haml by hswolff on Thursday January 06, 2011 @03:21PM (#2076976)
So awesome! Was looking just for this last week! Than you sir! Kudos! =)