From 8b81e09d72f6c2c1a54e84a42dfae85422209088 Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Sun, 1 Mar 2009 18:05:56 +0100 Subject: Don't raise an exception when there is no content to display for a given entry. --- cljssss-g.clj | 25 ++++++++++++++----------- index.st | 2 ++ 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/cljssss-g.clj b/cljssss-g.clj index d919abc..05b7d18 100644 --- a/cljssss-g.clj +++ b/cljssss-g.clj @@ -257,17 +257,20 @@ to merely being replaced with a div element)?" (defn show-subscriptions [user feed active-entry-id] (with-db - (.toString (doto (.getInstanceOf templates "index") - (.setAttributes {"feeds" (select-feeds user feed) - "entries" (when feed (select-entries user - feed - active-entry-id)) - "active_feed_id" feed - "active_feed_title" (and feed - (select-feed-name user feed)) - "title" "Subscriptions" - "xhtml_content" (and active-entry-id - (entry-xhtml-content active-entry-id))}))))) + (.toString + (let [xhtml-content (and active-entry-id + (entry-xhtml-content active-entry-id))] + (doto (.getInstanceOf templates "index") + (.setAttributes {"feeds" (select-feeds user feed) + "entries" (when feed (select-entries user + feed + active-entry-id)) + "active_feed_id" feed + "active_feed_title" (and feed + (select-feed-name user feed)) + "title" "Subscriptions" + "xhtml_content_p" (not (nil? xhtml-content)) + "xhtml_content" xhtml-content})))))) (defmacro with-session "Rebind Compojure's magic lexical variables as vars." diff --git a/index.st b/index.st index 0008c19..7b505a4 100644 --- a/index.st +++ b/index.st @@ -29,7 +29,9 @@ $if(entries)$ $! FIXME: Show content inline if possible. !$
  • $entry.title$

    + $if(xhtml_content_p)$
    $xhtml_content$
    + $endif$
  • $else$
  • -- cgit v1.2.3