At Mad Mimi I created an extension to Template which looks something like 

Template.from = function(id) {
  if(!$(id)) {
    console.warn("Missing template for " + id);
  } else {
    return new Template($(id).innerHTML.replace(/%23%7B(.*)%7D/g, "#{$1}"));

Then in your HTML you'd have script blocks that look something like this:

<script id="my_template" type="text/template">
  This is a #{template}.

And in your JS you'd simply go:

Template.from('my_template').evaluate({ template: "Template in my HTML 
where it should be" });

-- Marc

On Monday, November 26, 2012 5:57:27 PM UTC+2, kstubs wrote:
> Agreed!  I'm not too keen on this idea but have been searching for a 
> solution to better encapsulate my code and assets.  I do not consider domo 
> the answer, but was an interesting idea.
> Something we are doing in prototype with the Template class does put HTML 
> markup directly into the JS code.  I am trying to mediate this though by 
> collecting all of my template markup in a separate JS namespaced object. 
>  This is helping a lot.  And if you don't mind inline style markup in the 
> result, you can do the same thing, keep all of your style together in a 
> separate JS object.
> Karl..
> On Tuesday, November 20, 2012 2:53:18 AM UTC-7, Victor wrote:
>> Domo
>> From the J2EE developer's point of view it looks like return back to 
>> 2000s, to Servlets and tons of HTML/CSS markup in code. IMHO all advanced 
>> Java developers agree that moving HTML markup from Java code into separate 
>> JSP files was great step forward.

You received this message because you are subscribed to the Google Groups 
"Prototype &" group.
To view this discussion on the web visit
To post to this group, send email to
To unsubscribe from this group, send email to
For more options, visit this group at

Reply via email to