Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// function(key, env)
if (arguments.length === 2) {
key = arguments[0];
env = arguments[1];
}
// function(scope, key, env)
if (arguments.length === 3) {
key = arguments[0] + '.' + arguments[1];
env = arguments[2];
}
var data = env.data.root;
var result = traverse(data.i18n, key);
return new Handlebars.SafeString(result);
});
let containers;
if (l.containers && l.containers > 1) {
let i = 0;
while( i< l.containers) {
containers.push('jelly-container-' + i);
}
} else {
containers = ['jelly-container'];
}
const code = await readFile(path.resolve(__dirname, srcDir, categoryPath, l.path, 'index.js'));
const desc = await readFile(path.resolve(__dirname, srcDir, categoryPath, l.path, 'index.md'));
const context = {
dev: dev,
path: l.path,
title: l.title,
desc: new handlebars.SafeString(marked(desc.toString())),
code: new handlebars.SafeString(code.toString()),
group: group,
containers: containers,
daum: l.daum
};
if (lastL) lastL.selected = false;
l.selected = true;
lastL = l;
await writeFile(path.resolve(__dirname, distDir, l.path + '.html'), template(context))
}
} catch (e) {
console.error(e);
}
}
sectionHighlight: (section, pageName) => {
return (section === pageName) ? new Handlebars.SafeString(' aria-selected="true"') : '';
},
dispBytes: bytes => {
handlebars.registerHelper('thumbnail', function(url) {
return new handlebars.SafeString(
views.makeNonVoidElement('span', {
class: 'thumbnail',
style: 'background-image: url(\'{0}\')'.format(url)
}, views.makeVoidElement('img', {alt: 'thumbnail', src: url})));
});
export default title => {
let pageTitle = metadata.siteTitle;
if (title && title.length > 0 && title !== 'Home') {
pageTitle = title + ' :: ' + metadata.siteTitle;
}
return new SafeString(pageTitle);
};
Handlebars.registerHelper('GetBannerStatus', function() {
var monitored = this.monitored;
var status = this.status;
//var inCinemas = this.inCinemas;
//var date = new Date(inCinemas);
//var timeSince = new Date().getTime() - date.getTime();
//var numOfMonths = timeSince / 1000 / 60 / 60 / 24 / 30;
if (status === "inCinemas") {
return new Handlebars.SafeString('<div class="cinemas-banner"><i title="" class="icon-radarr-movie-cinemas grid-icon"></i> In Cinemas</div>');
}
if (status === "announced") {
return new Handlebars.SafeString('<div class="announced-banner"><i title="" class="icon-radarr-movie-announced grid-icon"></i> Announced</div>');
}
else if (!monitored) {
return new Handlebars.SafeString('<div class="announced-banner"><i title="" class="icon-radarr-series-unmonitored grid-icon"></i> Not Monitored</div>');
}
});
required: ["src", "as"],
error: "You must provide both `src` & `as` parameters to the data helper",
type: "data:params"
});
if (!params && inlineErrors) {
return new Handlebars.SafeString(errors["data:as"]());
}
var fileout = fileHelper.retrieveFile({
options: options,
params: params
});
if (fileout.inlineError && inlineErrors) {
return new Handlebars.SafeString(fileout.inlineError);
}
var data = fileHelper.retrieveFile({options: options, params: params}).data;
var sandbox = require("lodash/lang/cloneDeep")(compiler.frozen);
sandbox[params.as] = data;
/**
* Attempt to get a file from cache, or wherever
*/
return options.fn(sandbox);
};
};
const renderLayout = (layout, body) => {
const content = fm(fs.readFileSync(path.join(config.layouts, layout + '.html'), 'utf8'))
Object.assign(page, content.attributes)
const template = hbs.compile(content.body)
page.body = new hbs.SafeString(body)
let result = template(page, { data: { site } })
if (content.attributes.layout) {
result = renderLayout(content.attributes.layout, result)
}
return result
}
Handlebars.registerHelper('formatDate', function (date) {
return new Handlebars.SafeString(new Date(date).format('{Weekday}<br>{d}<br>{Month}<br>{yyyy}'));
});
Handlebars.registerHelper('dateLink', function (date) {
Handlebars.registerHelper( "selected", function( param, value ) {
return new Handlebars.SafeString( param === value ? "selected=\"selected\"" : "" );
});