client-side-templating

How to use precompiled templates in Handlebars with RequireJS?

南楼画角 提交于 2020-01-12 07:52:05
问题 I'd like to precompile my Handlebars templates, but I'm not sure how this works in development mode. Is it common practice have some background process like Guard running to constantly monitor changes to Handlebars template files? I'm using RequireJS to pull in templates; e.g.: define(['jquery', 'handlebars', 'text!templates/my_template'], function($, Handlebars, myTemplate) { // ... var data = {"some": "data", "some_more": "data"}; var templateFn = Handlebars.compile(myTemplate); $('#target'

Handlebars example not working

荒凉一梦 提交于 2020-01-05 04:57:09
问题 In my .hbs delivered by my node server: <script src="/javascripts/handlebars.min-latest.js"></script> <script id="entry-template" type="text/x-handlebars-template"> <div class="entry"> <h3>{{title}}</h3> <div class="body"> {{body}} </div> </div> </script> In my client-side javascript file: var source = $("#entry-template").html(); var template = Handlebars.compile(source); var context = {title: "My New Post", body: "This is my first post!"}; var html = template(context); console.log(html); My

client side server side templating nodejs

拈花ヽ惹草 提交于 2019-12-22 10:35:34
问题 I am working on a webapp using nodejs. I was originally going to just server side hbs template, but then I found out about backbone for client side templating. I found out it can fetch data from server then display it using hbs template, instead of server side generate entire html page and send. But then I also read somewhere people suggest that it is not good practice to have many ajax calls in client side to get data and display for one webpage, it would have so many request to server, and

Place client-side JavaScript templates in HTML or JavaScript?

百般思念 提交于 2019-12-22 06:00:24
问题 Should client-side templates like the following (using underscore's templating engine): <p class="foo"><%= bar %></p> be placed in an separate HTML file, or a separate JavaScript file? I know it could work both ways. For example, a JavaScript file could just contain a list of string variables like so: var cute = '<p class="the"><%= unicorn %></p>'; var fb = '<p class="new-design"><%= sucks %></p>'; But I have also seen the following: <script type="text/template" id="omg-template"> <span id=

how to use dustjs-linkedin as client side templating?

こ雲淡風輕ζ 提交于 2019-12-18 03:35:37
问题 I get the idea of server and client side templating, but dust.js confuses me a little bit. In order to use dust.js for client side templating, you need three steps: complie the template load the template render the template Right? But where do the templates come from? I saw two different methods: 1. <script> template <script> 2. <div> template </div> ... Both of them are in the DOM. Which is correct? I also notice that you can load the template via ajax, so the template won't be seen in the

using script tags for client side templates, why can't i load via src attribute?

让人想犯罪 __ 提交于 2019-12-14 03:52:32
问题 this works fine (am able to access the snippet in the dom by id) <script type="text/x-template" id="todo-item-template"> <div class="todo-view"> {blah} {blah} </div> </script> but if i put the template in an external resource, i can't find it in the dom: <script type="text/x-template" id="todo-item-template" src="todo-item-template.html"> chrome is giving me a warning which i think is irrelevant: Resource interpreted as Script but transferred with MIME type text/html: "http://localhost:8000

Javascript template parsing in mobile devices

你离开我真会死。 提交于 2019-12-13 05:35:46
问题 I have implemented basic template parser for javascript. it simply replaces variables within template string. i.e {event.date} will be 7/4/2013 I am using script tag to store template string <script id="date_template" type="text/html"> <span class="date" id="date_{event.id}"> {event.date} <span> </script> but it gives error in mobile devices so I have used div element for this <div style="display:none" id="date_template"> <span class="date" id="date_{event.id}"> {event.date} <span> </div> but

Illustrator/SVG to JavaScript workflow? (A templating library?)

拥有回忆 提交于 2019-12-10 16:29:13
问题 When "Saving as SVG" in Illustrator, this is the typical result: <?xml version="1.0" encoding="iso-8859-1"?> <!-- Generator: Adobe Illustrator 15.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) --> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="841.89px" height="595.28px" viewBox="0 0 841.89 595.28" style=

Getting TemplateSyntaxError: unexpected char u'#' on including a Mustache template in html file served by python Google App Engine

左心房为你撑大大i 提交于 2019-12-10 13:17:14
问题 I am getting a TemplateSyntaxError: unexpected char u'#' error, when I include a simple Mustache template in my HTML file being served by Python Google App Engine server. The mustache template that I want to include is: {{#item}} {{name}} {{/item}} My HTML file looks like this: <!DOCTYPE html> <html> <head> <script type="text/mustache-template" id="myTemplate"> {{#item}}{{name}}{{/item}} </script> </head> </html> Since, the template is wrapped around a script tag with type=text/mustache

client side server side templating nodejs

眉间皱痕 提交于 2019-12-05 18:28:04
I am working on a webapp using nodejs. I was originally going to just server side hbs template, but then I found out about backbone for client side templating. I found out it can fetch data from server then display it using hbs template, instead of server side generate entire html page and send. But then I also read somewhere people suggest that it is not good practice to have many ajax calls in client side to get data and display for one webpage, it would have so many request to server, and the page would appear to be slow. so I am wondering is there general rule how many requests can be made