Created
July 27, 2010 03:31
-
-
Save wmacgyver/491682 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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