Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/xenoterracide/template-plugin-haml
Haml Plugin for Template Toolkit
https://github.com/xenoterracide/template-plugin-haml
Last synced: 25 days ago
JSON representation
Haml Plugin for Template Toolkit
- Host: GitHub
- URL: https://github.com/xenoterracide/template-plugin-haml
- Owner: xenoterracide
- License: other
- Created: 2010-07-20T02:43:42.000Z (over 14 years ago)
- Default Branch: build/master
- Last Pushed: 2011-06-05T17:57:22.000Z (over 13 years ago)
- Last Synced: 2023-08-20T23:06:42.679Z (over 1 year ago)
- Language: Perl
- Homepage:
- Size: 156 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README
- Changelog: Changes
- License: LICENSE
Awesome Lists containing this project
README
NAME
Template::Plugin::Haml - Haml plugin for Template ToolkitVERSION
version 0.1.2SYNOPSIS
[%- USE Haml -%]
[%- FILTER haml -%]
%p Hello World
[%- END -%]
Hello World
DESCRIPTION
A thin wrapper around Text::Haml when you load the plugin it creates a
filter called haml that you can use in a normal way. A full description
of the Haml language can be found on the haml site
. Haml is a terse and whitespace sensitive html,
xhtml, and xml templating system. Compared to Template Toolkit however
it is relatively limited in what you can do. It by itself contains no
includes, conditionals, or loop constructs. So I've combined it here
with TT to make writing those kinds of templates with even less code
easier.EXAMPLE
input template
wrapper.tt!!! 5
%html
[% content %]hello.tt
[%- message='Hello World' %]
[%- USE Haml -%]
[%- WRAPPER wrapper.tt | haml -%]
[%- FILTER haml -%]
%head
%meta{:charset => "utf-8"}
%title hello
%body
%p [% message %]
%ul
[%- total=0; WHILE total < 5 %]
%li [% total=total+1 %][% total %]
[%- END -%]
[%- END -%]I'd like to draw some attention to the while loop here you have to have
the -'s in just the right spots to make it work because of Haml's
whitespace sensitivity.It's also important to note that will be in the
templates they're in. If you used PROCESS instead of WRAPPER above your
template would be output like...
...instead of...
Output
hello
hello world
- 1
- 2
- 3
- 4
- 5
Methods
init
initializes the the filter object
filter
method that actually does the transformation
ACKNOWLEDGEMENTS
Thanks to kd, mst, Khisanth, aef on #tt on irc.perl.org
for helping me figure out why my first try
didn't work
BUGS
Haml variables don't work
use TT style variables instead
AUTHOR
Caleb Cushing
COPYRIGHT AND LICENSE
This software is Copyright (c) 2011 by Caleb Cushing.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)