-
-
Notifications
You must be signed in to change notification settings - Fork 32
Edit Template
Template files are compiled with hiccup.
;; Define template options here
; @layout default
; @title misaki
;; definition your clojure function
(defn header [s] [:header [:h1 s]])
;; "site" variable to access template options
(header (:title site))
[:h2 "Posts"]
[:ul
(for [p (:posts site)]
[:li (:title p)])]
Template option format:
; @key value
Special options
-
layout
: Specify layout file. -
title
: Define template title. -
format
: Specify template format ("html5"
,"xhtml"
and"html4"
). No format template will be compiled byhiccup.core/html
.
Access template options
misaki provides site
variable to acess defined template options.
For example, you can access template title with (:title site)
.
Site updated date
(:date site)
is site updated date (org.joda.time.DateTime).
You can define functions in templare or layout.
However, special variable(e.g., site
and contents
) is not accessible in those functions.
(:posts site)
is post data list.
Post data format
-
:title
: Post title. -
:url
: Post URL. -
:date
: Post date (org.joda.time.DateTime). -
:file
: Post file (java.io.File). -
:tag
: Tag list for this post. -
:lazy-content
: Delayed post content. Useforce
to get post content.
Tag list format
-
:name
: Tag name. -
:url
: Tag page URL.
(:tags site)
is all post's tag data list.
Tag data format
-
:name
: Tag name. -
:url
: Tag page URL. -
:count
: Tag counts.
Codes are highlighted by google-code-prettify.
#-CODE
(println "hello")
CODE
CODE
can be replaced by any string.
If you define highlight setting, CODE
string specifies a language.
To define highlight setting, see Highlight Setting.
Layout options is same as template options.
; @title default title
; @format html5
[:head
[:title (:title site)]]
[:body contents]
Special variable
-
site
: Variable to access layout options. -
contents
: Variable to handle template contents.
Layout in layout
Layout file can contain :layout
option.
- default.clj
; @title default title
; @format html5
[:head [:title (:title site)]]
[:body contents]
- post.clj
; @layout default
; @title post default title
[:h1 (:title site)]
contents
Tag layout which is defined as :tag-layout
in _config.clj
has special site
keyword.
-
(:tag-name site)
: Tag name. -
(:posts site)
: Post list which contains this tag.
Back to Home