Overview

# 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
  (java.io.StringReader.
    (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
  (java.io.StringReader.
    (str "<html><body><input"
         " attr_message=\"value=good_morning alt=hello\""
         " value=\"GM\" alt=\"HELLO\">"
         "</input></body></html>"))
  []
  [:html] (localize-document :message :ja))

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

### Formatting HTML document

transformation "format-content"

(deftemplate test-page2
  (java.io.StringReader.
    "<html><body><p>This is %d dollars.</p></body></html>")
  [price]
  [: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.