underscore.js-templating

Issue with with 'use strict' and underscore.js

我的未来我决定 提交于 2021-02-07 06:09:44
问题 I've written an app using Yeoman and backbone.js. At the top of every js file I have specified 'use strict'; and when I run my grunt tasks jshint does not encounter any errors. I am able to build my app with grunt without issue however when I try to run the uglified js I get the following error: Uncaught SyntaxError: Strict mode code may not include a with statement I've searched the code base and the only things using a with statement is underscore. I'm new to strict mode so I'm not sure how

Issue with with 'use strict' and underscore.js

╄→尐↘猪︶ㄣ 提交于 2021-02-07 06:07:24
问题 I've written an app using Yeoman and backbone.js. At the top of every js file I have specified 'use strict'; and when I run my grunt tasks jshint does not encounter any errors. I am able to build my app with grunt without issue however when I try to run the uglified js I get the following error: Uncaught SyntaxError: Strict mode code may not include a with statement I've searched the code base and the only things using a with statement is underscore. I'm new to strict mode so I'm not sure how

Issue with with 'use strict' and underscore.js

≡放荡痞女 提交于 2021-02-07 06:07:13
问题 I've written an app using Yeoman and backbone.js. At the top of every js file I have specified 'use strict'; and when I run my grunt tasks jshint does not encounter any errors. I am able to build my app with grunt without issue however when I try to run the uglified js I get the following error: Uncaught SyntaxError: Strict mode code may not include a with statement I've searched the code base and the only things using a with statement is underscore. I'm new to strict mode so I'm not sure how

Templating using RequireJS (text.js plugin) and Underscore

时光总嘲笑我的痴心妄想 提交于 2020-01-23 15:39:05
问题 Need some opinions on the best way to manage templating in Underscore. I'm building a Backbone app and using Underscore to manage the templates. I started off by doing something like this in a 'template.js' file. templates = { template1: '<h1>Some HTML</h1>', template2: '<h1>Some more HTML and a <%= variable %></h1> ... } This gets messy. Fast. So, I looked into RequireJS's text plugin and that makes it much cleaner. Now, I have a bunch of HTML files, and I essentially store it into my

Underscore rendering [object HTMLDivElement]

五迷三道 提交于 2020-01-11 07:39:19
问题 I have an underscore template that is appending the following text " [object HTMLDivElement] " , but it's supposed to append value that "model.get('title')" returns. Here's my template: <script type="text/template" id="todoTemplate"> <div class='todoBlock'> <li class='appendedTodo'> <%= title %> </li> <button class='delete'>Delete</button><p> </div> </script> Here's my function: addTodoLi: function(model){ var todoData = model.get('title'); var compileTemplate = _.template( $('#todoTemplate')

How to find a paper size / printable size and set the header and footer on print?

≡放荡痞女 提交于 2020-01-06 09:04:18
问题 This is some what difficult me. My client require to print the data's with header and footer on each page. There is a chance to use a A4, A3, A5 and Landscape papers. How can i able to set the header and footer on each of the page? And how can i able to set a data length according to the page? is there a way to create print template? I am using underscore-template in Backbone . Any one suggest me a way please? 回答1: For your issue no difference which template engine you use. For doing

How to find a paper size / printable size and set the header and footer on print?

不问归期 提交于 2020-01-06 09:03:09
问题 This is some what difficult me. My client require to print the data's with header and footer on each page. There is a chance to use a A4, A3, A5 and Landscape papers. How can i able to set the header and footer on each of the page? And how can i able to set a data length according to the page? is there a way to create print template? I am using underscore-template in Backbone . Any one suggest me a way please? 回答1: For your issue no difference which template engine you use. For doing

Gulp, html templates and fragment loading

夙愿已清 提交于 2019-12-30 23:42:49
问题 I want to import html fragments at various places in a generated html file when I run it through a gulp task. The following is my gulp task: gulp.task('build_html', function () { gulp.src('resources/index.html') .pipe(template({ident: '1'})) .pipe(gulp.dest('frontend')); }); Inside the index.html file is a lot of html I would like to load from fragments, for example a bootstrap dropdown menu <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">

Django + Backbone: underscore template for login / logout

浪尽此生 提交于 2019-12-25 08:00:08
问题 I am building a SPA using Django and Backbone. Until now most of my templates have been on the Django side, but I'm now moving to templating with Backbone/Underscore. The only thing I'm unsure about is how to manage page reload with respect to authentication. I do not have a separate login page, but rather a dropdown login form on the app's menu bar (a Bootstrap navbar), which makes $.ajax requests for login/out actions. I want to keep the app interface publicly available, and only render

Underscore, Nested Group By and Generate a JSON

与世无争的帅哥 提交于 2019-12-25 04:19:58
问题 I have an array of objects with duplicates and I'm trying to get a unique listing, where uniqueness is defined by a subset of the properties of the object. For example, Current JSON Object: [{"x":6811,"y":15551,"a":"a"}, {"x":6811,"y":15551,"a":"b"}, {"x":6811,"y":15551,"a":"c"}, {"x":6811,"y":15552,"a":"c"}, {"x":6812,"y":15551,"a":"c"}] How to group by two property The last result is [{"x":6811,"y":15551,"a":["a","b","c"]}, {"x":6811,"y":15552,"a":["c"]}, {"x":6812,"y":15551,"a":["c"]}] How