kevsmith / herml
- Source
- Commits
- Network (4)
- Issues (1)
- Downloads (1)
- Wiki (1)
- Graphs
-
Tree:
2942bd1
herml / README
| 06cced29 » | seancribbs | 2009-02-21 | 1 | Welcome to herml, the Haml-like templating language! | |
| ed9e912c » | kevsmith | 2008-12-13 | 2 | ||
| 3 | Building: | ||||
| 2942bd1d » | seancribbs | 2009-06-19 | 4 | 1) Install leex 0.3 or greater. Putting it in your $ERLANG_HOME/lib is best. | |
| 5 | leex is included with R13B01. | ||||
| 06cced29 » | seancribbs | 2009-02-21 | 6 | 2) Clone the herml repo from Github. | |
| 7 | 3) Run make | ||||
| 8 | 4) Put the herml/ebin directory somewhere on your code path: | ||||
| 9 | 4a) Symlink the top-level herml directory into your $ERLANG_HOME/lib directory | ||||
| ed9e912c » | kevsmith | 2008-12-13 | 10 | -or- | |
| 06cced29 » | seancribbs | 2009-02-21 | 11 | 4b) Use the -pz or -pa switches on erl to place herml/ebin onto your code path | |
| ed9e912c » | kevsmith | 2008-12-13 | 12 | ||
| 726b0c7e » | asceth | 2009-01-05 | 13 | Using in Sinan: | |
| 14 | 1) Clone the herml repo from Github | ||||
| 15 | 2) Run `make special` in the herml directory | ||||
| 16 | 3) Make sure your sinan project can find the herml repo | ||||
| 17 | 3a) Clone inside your projects lib directory | ||||
| 18 | -or- | ||||
| 19 | 3b) Symlink the herml directory to your projects lib directory | ||||
| 20 | |||||
| 21 | 4) Keep it up to date: | ||||
| 22 | a) Pull down latest changes | ||||
| 23 | b) `make clean` | ||||
| 24 | c) `make special` | ||||
| 25 | |||||
| ed9e912c » | kevsmith | 2008-12-13 | 26 | Running tests: | |
| 27 | 1) Run make clean tests | ||||
| 28 | |||||
| 29 | |||||
| 30 | Using herml: | ||||
| 31 | |||||
| e9620091 » | seancribbs | 2009-06-19 | 32 | 1) Start up a herml_manager process for your template directory: | |
| ed9e912c » | kevsmith | 2008-12-13 | 33 | ||
| e9620091 » | seancribbs | 2009-06-19 | 34 | 1> herml_manager:start_link(my_web_app,"/path/to/templates"). | |
| ed9e912c » | kevsmith | 2008-12-13 | 35 | ||
| 2942bd1d » | seancribbs | 2009-06-19 | 36 | Note: herml_manager can cache the compiled template and use it over and over. | |
| ed9e912c » | kevsmith | 2008-12-13 | 37 | ||
| e9620091 » | seancribbs | 2009-06-19 | 38 | 2) Execute the template by calling the herml_manager process: | |
| ed9e912c » | kevsmith | 2008-12-13 | 39 | ||
| e9620091 » | seancribbs | 2009-06-19 | 40 | 2> Result = herml_manager:execute_template("file.herml", Env). | |
| ed9e912c » | kevsmith | 2008-12-13 | 41 | ||
| 42 | Note: Env is a proplist containing the execution environment for the | ||||
| 43 | template. herml expects all variable names to be Erlang strings. For | ||||
| 44 | example, here's a valid environment proplists: [{"UserName", "herml"}]. | ||||
| 45 | |||||
| 46 | The UserName variable would be referenced from herml as @UserName. | ||||
| 47 | |||||
| e9620091 » | seancribbs | 2009-06-19 | 48 | Another note: For efficiency reasons, herml_manager:execute_template/2,3,4 | |
| 49 | returns iolists when it executes templates. If you want to view the | ||||
| 50 | template output as a standard string, you can use the io module | ||||
| 51 | to flatten the iolist: | ||||
| ed9e912c » | kevsmith | 2008-12-13 | 52 | ||
| 53 | 3> io:format("~s", [Result]). | ||||
