Giter Club home page Giter Club logo

Comments (3)

ifesdjeen avatar ifesdjeen commented on August 21, 2024

It looks like the example is outdated. Here's a new version:

(ns net.cgrand.enlive-html.examples
  (:use [net.cgrand.enlive-html :as html :only [clone-for deftemplate at content set-attr attr? strict-mode substitute]] :reload))

(deftemplate microblog-template "net/cgrand/enlive_html/example.html"
 [title posts]
   [:title] (content title)
   [:h1] (content title)
   [:div.no-msg] (if (empty? posts)
                   identity
                   (substitute nil))
   [:div.post] (clone-for [{:keys [title body]} posts]
                          [:h2 :a] (content title)
                          [:p] (content body))
   [[:a (attr? :href)]] (set-attr :title "it's a link"))

(defn render
  [nodes]
  (apply str nodes))

(comment
  (render (microblog-template "Hello user!"
               [{:title "post #1"
                 :body "hello with dangerous chars: <>&"}
                {:title "post #2"
                 :body "dolor ipsum"}])))

It will yield following html:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
  <head>
    <title>Hello user!</title>
  </head>
  <body>
    <h1>Hello user!</h1>

    <div class="post">
      <h2><a title="it's a link" href="http://cgrand.net/">post #1</a></h2>
      <p>hello with dangerous chars: &lt;&gt;&amp;</p>
    </div><div class="post">
      <h2><a title="it's a link" href="http://cgrand.net/">post #2</a></h2>
      <p>dolor ipsum</p>
    </div>
  </body>
</html>

from enlive.

ifesdjeen avatar ifesdjeen commented on August 21, 2024

ok, fixed and merged to upstream: 053884e

could anyone please close the issue? I don't really have rights to do so //cc @cgrand @vemv

from enlive.

vemv avatar vemv commented on August 21, 2024

Awesome, thank you. Glad to see Enlive active again!

from enlive.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.