Skip to content

Instantly share code, notes, and snippets.

@wmacgyver
Created July 27, 2010 03:31
Show Gist options
  • Save wmacgyver/491682 to your computer and use it in GitHub Desktop.
Save wmacgyver/491682 to your computer and use it in GitHub Desktop.
(ns mywebapp.add
(:require [net.cgrand.enlive-html :as html])
(:use clojure.contrib.json)
(:use clojure.contrib.prxml))
(html/deftemplate add-view "views/addtwonums.html"
[ctxt]
[:p#answer] (html/content (:answer ctxt)))
(defn add-two-nums [a b]
(add-view {:answer (str "the answer is " (+ a b))}))
(defn add-two-nums-noanswer []
(add-view {}))
(defn add-two-nums-json [a b]
(json-str [:answer (+ a b)]))
(defn add-two-nums-xml [a b]
(with-out-str (prxml [:answer (+ a b)])))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment