javascript - Backbone Inline HTML Templates versus External Templating -


& lt; Body & gt; & Lt; Div id = "container" & gt; & Lt; Header & gt; & Lt; / Header & gt; & Lt; NAV & gt; & Lt; / Neo & gt; & Lt; Div id = "pagecontent" & gt; & Lt; / Div & gt; & Lt; Footer & gt; & Lt; / Footer & gt; & Lt; / Div & gt; & Lt ;! - Featured Articles / Homepage Templates - & gt; & Lt; Script type = "text / template" id = "validation" & gt; & Lt; Link rel = "stylesheet" href = "css / homepagecontent.css" /> & Lt; Section id = "banner" & gt; & Lt; / Section & gt; & Lt; On one hand & gt; & Lt; Div & gt; & Lt; / Div & gt; & Lt; Div & gt; & Lt; / Div & gt; & Lt; / One side & gt; & Lt; Section id = "main" & gt; & Lt; / Section & gt; & Lt; Section id = "opinion" & gt; & Lt; Div & gt; & Lt; / Div & gt; & Lt; Div & gt; & Lt; / Div & gt; & Lt; Div & gt; & Lt; / Div & gt; & Lt; / Section & gt; & Lt; Section id = "travel" & gt; & Lt; Div & gt; & Lt; / Div & gt; & Lt; Div & gt; & Lt; / Div & gt; & Lt; Div & gt; & Lt; / Div & gt; & Lt; / Section & gt; & Lt; / Script & gt; & Lt ;! - Content Articles Template - & gt; & Lt; Script type = "text / template" id = "content article" & gt; & Lt; Link rel = "stylesheet" href = "css / categorypagecontent.css" /> & Lt; Section id = "main" & gt; & Lt; / Section & gt; & Lt; On one hand & gt; & Lt; / One side & gt; & Lt; / Script & gt; & Lt ;! - Require.js Reference - & gt; & Lt; Script src = "/ js / libs / require.js" data-key = "/ js / app.js" & gt; & Lt; / Script & gt; & Lt; / Body & gt;

Can I do HTML externally instead? If so, how will I extrude it (i.e. using the view), then it is as follows:

   
  Define (['underscore', 'backbone' , 'Collection / BannerCollection', 'Collection / Featured Articulation',], Function (_, Backbone, Bannerclone, Featured Articulation) {var attributesArticsView = backbone.VisualExtension ({L: $ ('#Page Content'), Start: Function () {This render ();}, render: function () {var is that = it; var Template = _Template ($ ('#feThitics') .HTML (), {}) that. $ El.html (template); return;}}); Features Returned Articles View;};   

I'm reading about partial, but best practice requires some guidance and if / inline html should be divided.

I can not remember a template manager (this author can come back) this short snippet Found found:

TemplateManager = {Template: {}, // Get the templates cache: function (id, callback) {var template = this.templates [id]; If (template) {// will return a cached version if this callback exists; } And {var that = this; // Return Fetch, Cache, and Template $ .get (ID + ".HTML", Function (Template) {that.templates [id] = Template; Callback (that.templates [id]);}); }}};

This template fetches the file, it caches and calls a callback function after loading, such as:

TemplateManager. Get ('path / to / your / template', function (resp) {// resp template markup;});

Hope this helps.

Update

Bella is working here:



Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -