hi, I'm starting to modify the One sample application and can't get
the hang of rendering a new view. I've tried looking at some forked
projects but am coming up short.
I created a basic template /templates/game.html:
<_within file="application.html">
<div id="content">
<div id="game">
<h1 id="header">My game goes here. </h1>
</div>
</div>
</_within>
I edited /public/design.html to add a link:
<ul>
<li><a href="/design/form.html">Form</a></li>
<li><a href="/design/greeting.html">Greeting</a></li>
<li><a href="/design/game.html">Play the game</a></li>
</ul>
And now I can click on the link at http://localhost/design.html and
see the template.
To check if I can see this in Development mode, in one/sample/
view.cljs I changed the render method for :init,
(defmethod render :init [_]
(fx/my-initialize-views (:game snippets)))
And in one/sample/animation.cljs added:
(defn my-initialize-views
[game-html]
(let [content (xpath "//div[@id='content']")]
(destroy-children! content)
(set-html! content game-html)
))
And in one/sample/snippets.clj modified the macro snippets:
(defmacro snippets
"Expands to a map of HTML snippets which are extracted from the
design templates."
[]
{:form (snippet "form.html" [:div#form])
:greeting (snippet "greeting.html" [:div#greeting])
:game (snippet "game.html" [:div#game])})
However when I browse to Development the content div is empty -- the
html looks like:
<div class="container">
<div id="content"></div>
<div id="options"></div>
<footer></footer>
</div> <!-- /container -->
Does anyone have some suggestions on how to display the game.html
template when first browsing to Development? Thanks.
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en