Template file†
Template files are compiled with hiccup.
Example†
;; Define template options here ; @layout default ; @title misaki ;; define a custom clojure function (defn header [s] [:header [:h1 s]]) ;; passing the "site" variable for access to template options (header (:title site)) (h2 "Posts") (post-list) ;; or you can write posts list manually ; [:ul ; (for [p (:posts site)] ; [:li (:title p)])]
Template options†
Template option format:
; @key value
Special options†
layout
: Specify layout file.title
: Define template title.format
: Specify template format ("html5"
,"xhtml"
,"html4"
). No format template will be compiled byhiccup.core/html
.
Access template options†
misaki provides a site
variable with access to various template options. For example, you can access the template title with (:title site)
.
Site updated date†
(:date site)
is site updated date (org.joda.time.DateTime).
Functions†
You can define your own function in template or layout. However, the special misaki variables (e.g., site
and contents
) are not accessible in those functions.
Posts†
(:posts site)
contains a list of clojure hash-maps, one for each blog post.
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.:tag-name
: Joined tag names. This data is only contained by tag search.:index
: Index filename string generated by*url-base*
and*index-name*
.:prev
: Previous post data.:next
: Next post data.lazy-content
: Delayed post content. Useforce
to get post content.
Tag list format†
:name
: Tag name.:url
: Tag page URL.
Post tags†
(:tags site)
contains a list of hash-maps for a post's tags.
Tag data format†
:name
: Tag name.:url
: Tag page URL.:count
: Tag counts.
Next/Prev page link†
With pagination, (:next-url site)
and (:prev-url site)
are provided.
:next-url
: Next page's URL:prev-url
: Previous page's URL
Code Highlight†
Code is highlighted using google-code-prettify.
#-CODE (println "hello") CODE or ##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 file†
Example†
Layout options are the same as template options.
; @title default title ; @format html5 [:head [:title (:title site)]] [:body contents]
Special variables†
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†
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 the tag.