Skip to content
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

add flag to use template.contents() instead of template.children() to include comments #105

Open
SimianLogic opened this issue Aug 11, 2016 · 1 comment

Comments

@SimianLogic
Copy link

SimianLogic commented Aug 11, 2016

The change here is fairly straightforward, but wanted to get your thoughts before submitting a pull request. I'm creating templates in standalone html files, pretty much like:

<!-- filename.html -->
<h1>Something something something</h1>

My intention was for the filename comment to get rendered so that anyone looking at the rendered webpage later that wanted to change some copy could go find that file easily and make their edits. After tracing through the plugin, it looks like the comments disappear on line 212 of jquery.loadTemplate.js

var $templateHtml = template.children().clone(true);

By replacing children() with contents() we get all of the nodes (including the comments, yay!)... but that only works with HTML comments. If you're using

//javascript comments

or your template was declared on the same page, it would just render the plain text of your comment.

So what I'd like to implement is an extra option to use contents instead of children (the default would be false). Something like "renderComments" or "useContents" or "renderAllNodes" which would default to false. Flip it on if you know what you're doing, but otherwise everything would work exactly the same.

What do you think?

@codepb
Copy link
Owner

codepb commented Sep 28, 2016

yes, I think this should be fine. I don't know if it would have any side effects, so would need to be tested to make sure.

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

No branches or pull requests

2 participants