New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Readme: add Tips :: Match/replace the whole `body` #15

Closed
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
3 participants
@holyjak
Copy link
Contributor

holyjak commented Apr 8, 2014

I spent considerable time finding out why (deftemplate ... {[:body] (content ..)}) does nothing and
would like to help other users avoid the same problem. (Though hopefully only few need it.)

For more info/background, see the blog post http://theholyjava.wordpress.com/2014/04/08/kioo-how-to-replace-the-whole-body/ (feedback warmly welcomed)

Jakub Holy
Readme: add Tips :: Match/replace the whole `body`
I spent considerable time finding out why `(deftemplate ... {[:body] (content ..)})` does nothing and
would like to help other users avoid the same problem. (Though hopefully only few need it.)

For more info/background, see the blog post http://theholyjava.wordpress.com/2014/04/08/kioo-how-to-replace-the-whole-body/ (feedback warmly welcomed)
@ckirkendall

This comment has been minimized.

Copy link
Owner

ckirkendall commented Apr 9, 2014

You are mixing two concepts here. A template is not suppose to have a sub selector. Its an internal implementation detail that makes it work. I don't see why you are even using the deftemplate in this case. It is not doing anything for you. You would just use defsnippet.

Instead of this:

(defsnippet kiootest-one "kiootest.html" [:#contentOne] [_]
  {[:#name] (content "Kioo")})

(deftemplate kiootest "kiootest.html" [_]
  [:body] {[:body] (substitute (kiootest-one _))})
;;  ^- custom root selector
;;            ^- inside the selected <body..>..</body>, match the body element itself

(om/root #(om/component (kiootest %)) (atom {}) 
         {:target (. js/document (getElementById "om-shop-list2"))})

Is there a reason this doesn't work

(defsnippet kiootest-one "kiootest.html" [:#contentOne] [_]
  {[:#name] (content "Kioo")})


(om/root #(om/component (kiootest-one %)) (atom {}) 
         {:target (. js/document (getElementById "om-shop-list2"))})
@holyjak

This comment has been minimized.

Copy link
Contributor

holyjak commented Apr 9, 2014

Thanks a lot! I mistakendly believed that snippet can only be used inside a template.

Sorry for wasting your time :-)

@holyjak holyjak closed this Apr 9, 2014

@danielsz

This comment has been minimized.

Copy link

danielsz commented Sep 15, 2014

I had made the same assumption, and spent some hours trying to figure out what was happening.

May I kindly suggest to explain in the README what deftemplate does or return, as opposed to defsnippet. Purely out of compassion, please.

@ckirkendall

This comment has been minimized.

Copy link
Owner

ckirkendall commented Sep 16, 2014

@danielsz - I added the template and snippet section to the Readme.md. If you could, please take a look and let me know if you think it needs to be more clear.

@danielsz

This comment has been minimized.

Copy link

danielsz commented Sep 16, 2014

Yes! This tells us what we should know regarding snippets and templates. Nice job. Thank you!

On a more general note, I would argue that the term "kioo component" is unfortunate. Users come to kioo after having spent some time with a Clojurescript React library, which already refers to its artefacts as components. In my mind, for example, Om and Reagent wrap React components, while Sablono and Kioo provide a mechanism to generate React-approved tags and attributes. Talking about "kioo components" causes semantic overload, even though I'm sure you can make the case for them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment