enlive-utils / README

# enlive-utils

Utilities for Enlive HTML template system.

## Usage

### Localizing HTML document

transformation "localize-document"

;; define messages (jp.taka2ru/i18n)
(gen-resource [:message :ja]
  :hello "Konnichiwa"
  :good_morning "Ohayo"
  :price "Korewa %d Yen desu.")

(deftemplate test-page1
    (str "<html><body><p message=\"hello\"></p>"
         "<p message=\"good_morning\"></p></body></html>"))
  [:html] (localize-document :message :ja))

=> "<html><body><p>Konnichiwa</p><p>Ohayo</p></body></html>"

### Localizing Attributes of HTML document

use "attr_message" attribute, which values are separeted by spaces.

(deftemplate test-page3
    (str "<html><body><input"
         " attr_message=\"value=good_morning alt=hello\""
         " value=\"GM\" alt=\"HELLO\">"
  [:html] (localize-document :message :ja))

=> "<html><body><input alt=\"Konnichiwa\" value=\"Ohayo\" /></body></html>"

### Formatting HTML document

transformation "format-content"

(deftemplate test-page2
    "<html><body><p>This is %d dollars.</p></body></html>")
  [:p] (format-content price))

=> "<html><body><p>This is 5000 dollars.</p></body></html>"

## License

Copyright (C) 2011 Tetsuya Takatsuru

Distributed under the Eclipse Public License, the same as Clojure.
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.