norman / lua-haml

Haml for Lua

This URL has Read+Write access

name age message
file .gitignore Fri Sep 11 12:21:51 -0700 2009 Added escaped filter and refactored filter api. [norman]
file .gitmodules Thu Sep 17 07:31:57 -0700 2009 Added halm-spec submodule. [norman]
file README.md Mon Dec 07 08:05:04 -0800 2009 Added support for boolean attributes. [norman]
directory bin/ Wed Nov 25 07:46:50 -0800 2009 Fixed HTML(4|5) self-closing tag output. [norman]
file haml.lua Thu Dec 03 09:51:31 -0800 2009 Added support for escape_html feature, &= and !=. [norman]
directory haml/ Mon Dec 07 18:32:04 -0800 2009 Fixed some issues with inline tag closing. [norman]
file luahaml-scm-1.rockspec Wed Nov 18 13:32:43 -0800 2009 Added explicit dependency on LPeg. [norman]
directory sample_apps/ Mon Sep 07 20:46:22 -0700 2009 Fixed sample app. [norman]
directory spec/ Mon Dec 07 08:05:04 -0800 2009 Added support for boolean attributes. [norman]
README.md

Lua Haml

About

Lua Haml is an implementation of the Haml markup language for Lua. Though it is implemented in Lua, its design makes it easily adaptable to almost any language, and it includes an experimental renderer for Haml for Ruby. Lua Haml is "just Haml," with no extending of the original language.

A Haml language reference can be found here.

Lua Haml currently supports the main features of Ruby's Haml, and can be used for real work. However, many of the finer details of the language, some of them important, are still being implemented.

Working features

The following features of Ruby's Haml are working in Lua Haml:

  • Options: escape_html, format, autoclose, encoding
  • Plain text
  • Escapes
  • HTML elements
  • Ruby-style attributes
  • HTML-style attributes
  • Classes and id's (. and #)
  • Implicit div elements
  • Self-closing tags
  • Doctypes and XML prologs
  • Haml comments
  • Code evaluation
  • Ruby-style string interpolation ("#{var}")
  • Running Lua
  • Lua blocks
  • Whitespace preservation (via filter)
  • Filters: plain, javascript, preserve, escaped, lua, markdown, custom
  • Partial templates. Lua Haml provides a simple default partial implementation, which can be overridden by frameworks as they see fit.
  • HTML comments
  • Conditional comments
  • Escaping HTML
  • Unescaping HTML
  • Boolean attributes

To do

The following features of Ruby's Haml are not yet working in Lua Haml:

  • Options: suppress_eval, attr_wrapper, preserve
  • Attribute methods
  • Whitespace removal
  • Whitespace preservation (implicit)
  • Multiline content
  • Helpers

The following features will likely not be implemented in Lua Haml:

  • Object reference

To see an example of what you can do with the currently supported features, view the "currently supported language" template in the spec directory.

I probably won't implement Sass for a while yet, possibly never. However if I do implement it, it will definitely be as a separate project.

Getting it

Install using LuaRocks:

luarocks install luahaml --from=http://luarocks.org/repositories/rocks-cvs/

Don't be put off by the "CVS" in the URL, this will install the latest Lua Haml from the stable branch on Github.

Hacking it

The Github repository is located at:

git://github.com/norman/lua-haml.git

To run the specs, you should also install Telescope:

luarocks install telescope --from=http://luarocks.org/repositories/rocks-cvs/

You can then run them using the ./bin/spec script in the repository.

Bug reports

Please report them on the Github issue tracker.

Author

Norman Clarke

Attributions

Some of the sample files in test/samples were taken from Ruby's Haml.

Thanks

To Hampton Caitlin and Nathan Weizenbaum for their work on the original Haml.

License

The MIT License

Copyright (c) 2009 Norman Clarke

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.