Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
onInitTemplate() {
// Handlebars templates
Handlebars.registerPartial('accounting-payments-row-template', $('#accounting-payments-row-template').html());
this.templatePaymentsTable = Handlebars.compile($('#accounting-payments-template').html());
this.templateEntriesExitsTable = Handlebars.compile($('#accounting-entries-exits-template').html());
}
define(function(require) {
var Backbone = require('backbone'),
Handlebars = require('handlebars'),
$ = require('jquery'),
d3 = require('d3'),
_ = require('underscore'),
Where = require('summary/where'),
util = require('summary/util'),
ScorpionResult = require('summary/scorpionresult'),
ScorpionResultView = require('summary/scorpionresultview'),
Query = require('summary/query');
var ScorpionResultsView = Backbone.View.extend({
template: Handlebars.compile($("#scorpion-results-template").html()),
initialize: function(attrs) {
this.state = {
locked: null, // null = base results, int = scorpion result views
where: null, // global where object
query: null
};
_.extend(this.state, attrs);
this.listenTo(this.collection, 'add', this.addTo);
this.listenTo(this.collection, 'reset', this.reset);
this.listenTo(this.state.query, 'change:db', this.clear);
this.listenTo(this.state.query, 'change:table', this.clear);
},
test( 'formatDate', function( t ){
t.plan(6);
var dates = [
'2013-09-30T15:00:00.340Z',
'2013/09/30 15:00:00 +0000',
'Mon Sep 30 2013 15:00:00 GMT-0700 (PDT)',
1380578400000,
'1380578400000'
];
var tpl = Handlebars.compile('{{formatDate this "%A, %B %o %Y"}}');
t.equal( tpl( dates[0] ), 'Monday, September 30th 2013', 'date successfully formatted' );
var tpl2 = Handlebars.compile('{{formatDate this "%b. %o %Y"}}');
t.equal( tpl2( dates[1] ), 'Sep. 30th 2013', 'date successfully formatted' );
var tpl3 = Handlebars.compile('{{formatDate this "%A at %-l:%M%p" 0 }}');
t.equal( tpl3( dates[2] ), 'Monday at 10:00PM', 'date successfully formatted' );
var tpl4 = Handlebars.compile('{{formatDate this "%A at %-l:%M%p" -120 }}');
t.equal( tpl4( dates[2] ), 'Monday at 8:00PM', 'date successfully formatted' );
var tpl5 = Handlebars.compile('{{formatDate this "%v"}}');
t.equal( tpl5( dates[3] ), '30-Sep-2013', 'date successfully formatted' );
t.equal( tpl5( dates[4] ), '30-Sep-2013', 'date successfully formatted' );
});
define(function(require) {
'use strict';
var Nex = require('nex'),
Handlebars = require('handlebars'),
homeTemplate = require('text!./homeTemplate.html'),
Layout = require('layouts/basicLayout/layout'),
utilities = require('utilities');
return Nex.defineComponent('home-page', {
template: Handlebars.compile(homeTemplate),
layout: Layout,
render: function() {
this.html(this.template(this));
utilities.formatCode(this);
return this;
}
});
});
fs.readFile(filepath, 'utf-8', (err, content) => {
if (!err) resolve(Handlebars.compile(content));
else reject(err);
});
});
'handlebars': function(content, context) {
var tmpl = Handlebars.compile(content);
return tmpl(context);
},
'dust': function(content, context) {
fs.readFile(pathToFile, 'utf8', function(err, data) {
var template = Handlebars.compile(data),
page = template(context);
callback({
mimeType: 'text/html',
data: new Buffer(page)
});
});
}
function (next) {
params.fn = Handlebars.compile(params.ast, _.merge({data: true}, params.options));
next();
},
notify(events.handlebarsAfterCompile)
function renderInside(content, layoutPath, metadata) {
const path = `${dir}/tools/layouts/${layoutPath}`;
const contents = hbs.compile(content)(metadata);
const layout = fs.readFileSync(path).toString();
const file = matter(layout);
const template = hbs.compile(file.content);
const output = template(Object.assign({}, metadata, file.data, { contents }));
if(file.data.layout) {
return renderInside(output, file.data.layout, metadata);
} else {
return output
}
}
var LinkRowView = require('js/views/links/LinkRowView');
var ErrorHandler = require('js/views/ErrorHandler');
var linkTable = require('text!js/templates/links/linkTable.hbs');
return Backbone.View.extend(_.extend({
events: {
'click #btn-link-create': '_create',
'click #btn-link-clear': '_resetModel'
},
bindings: {
'#linkName': 'linkName',
'#url': 'url'
},
template: Handlebars.compile(linkTable),
initialize: function () {
this.listenTo(this.collection, 'sync', this.renderTable);
},
render: function () {
this.$el.html(this.template());
this._resetModel();
return this;
},
renderTable: function () {
var $tbody = this.$('tbody').empty();
this.collection.each(function (link) {
$tbody.append(new LinkRowView({
model: link
}).render().el)
});