Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
_getSlotTemplate: function(slotName) {
var template = this._htmlTemplatesBySlot[slotName];
if (!template) {
var templateSrc = this._htmlBySlot[slotName];
if (!templateSrc) {
return null;
}
// In order to compile the HTML for the slot into a Marko template, we need to provide a faux
// template path. The path doesn't really matter unless the compiled template needs to import
// external tags or templates.
var templatePath = nodePath.resolve(__dirname, '..', generateTempFilename(slotName));
template = marko.load(templatePath, templateSrc, { preserveWhitespace: true, writeToDisk: false });
// Cache the loaded template:
this._htmlTemplatesBySlot[slotName] = template;
// The Marko template compiled to JS and required. Let's delete it out of the require cache
// to avoid a memory leak
delete require.cache[templatePath + '.js'];
}
return template;
},
function run() {
console.log('Preparing client-side tests...');
running = true;
fileModified = false;
var pageTemplate = require('marko').load(require.resolve('../fixtures/pages/server-init/template.marko'));
var pageLayoutTemplate = require('marko').load(require.resolve('./page-layout.marko'));
var pageHtmlFile = path.join(outputDir, 'test-page.html');
var out = fs.createWriteStream(pageHtmlFile, 'utf8');
console.log('Rendering HTML page...');
pageTemplate.render({
layout: pageLayoutTemplate
}, out)
.on('finish', function() {
console.log('Running client tests using mocha-phantomjs...');
spawn(
'npm',
['run', 'mocha-phantomjs-run', '--loglevel=silent'],
{
cwd: rootDir,
var template = require('marko').load(require.resolve('./template.marko'));
module.exports = require('marko/legacy-components').defineComponent({
createOut: template.createOut,
renderer: function(input, out) {
template.render({
name: input.name
},
out);
},
setName: function(name) {
this.getEl('name').innerHTML = name;
}
});
var template = require('marko').load(require.resolve('./template.marko'));
exports.render = function(input, out) {
var viewModel = {
};
template.render(viewModel, out);
};
var template = require('marko').load(require.resolve('./template.marko'));
exports.render = function (input, out) {
var viewModel = {};
template.render(viewModel, out);
};
var template = require('marko').load(require.resolve('./template.marko'));
exports.render = function render(input, out) {
template.render({
label: input.label
},
out);
};
var template = require('marko').load(require.resolve('./template.marko'));
module.exports = function(input, out) {
var className = input['class'] || 'app-hello';
template.render(
{
name: input.name,
className: className,
widgetConfig: {
name: input.name
}
},
out);
};
const http = require('http')
const EventEmitter = require('events')
const express = require('express')
const bodyParser = require('body-parser')
const marko = require('marko')
const markoExpress = require('marko/express')
const TestPage = marko.load(require('./pages/test-page'))
const { Server: WebSocketServer } = require('ws')
class Server extends EventEmitter {
constructor ({ outputDir, pageLasso, dependencies, testPage }) {
super()
const app = this._app = express()
app.use(bodyParser.json({ limit: '100mb' }))
app.use(markoExpress())
testPage = (testPage && marko.load(testPage)) || TestPage
app.get('/', (req, res) => {
this.emit('start')
var template = require('marko').load(require.resolve('./template.marko'));
module.exports = function(input, out) {
var width = input.width || 800;
template.render({
width: width,
invokeBody: input.invokeBody
}, out);
};
const pageTemplatePath = require.resolve('../views/page.marko');
const pageTemplate = require('marko').load(pageTemplatePath, { writeToDisk:false });
module.exports = {
home: function* () {
const app = require('../assets/build/server.marko.bundle');
const pageConfig = {
listData: require('../mock/list'),
bannerData: require('../mock/banner')
};
this.body = pageTemplate.renderToString({ pageConfig, app, globalData: JSON.stringify(pageConfig) });
}
}