GithubHelp home page GithubHelp logo

template-plugin-haml's Introduction

NAME
    Template::Plugin::Haml - Haml plugin for Template Toolkit

VERSION
    version 0.1.2

SYNOPSIS
            [%- USE Haml -%]
            [%- FILTER haml -%]
            %p Hello World
            [%- END -%]

            <p>Hello World</p>

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
    <http://haml-lang.com>. 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 <tags> will be </closed> in the
    templates they're in. If you used PROCESS instead of WRAPPER above your
    template would be output like

            ...
            <html></html>
             <head>
            ...

    instead of...

   Output
            <!DOCTYPE html>
            <html>
             <head>
              <meta charset='utf-8' />
              <title>hello</title>
             </head>
             <body>
              <p>hello world</p>
              <ul>
               <li>1</li>
               <li>2</li>
               <li>3</li>
               <li>4</li>
               <li>5</li>
              </ul>
             </body>
            </html>

  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
    <irc://irc.perl.org/tt> 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 <[email protected]>

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)

template-plugin-haml's People

Contributors

xenoterracide avatar

Stargazers

Jared Freeze avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.