1. taka2ru
  2. enlive-utils


enlive-utils /

Filename Size Date modified Message
103 B
1.4 KB
286 B
# 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.