Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

marko

Package Overview
Dependencies
Maintainers
2
Versions
936
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

marko - npm Package Compare versions

Comparing version 1.6.1 to 2.0.0

CHANGELOG.md

34

compiler/taglibs/taglib-loader.js

@@ -35,3 +35,4 @@ var fs ;

type: 'string',
targetProperty: null
targetProperty: null,
preserveName: false
}

@@ -265,4 +266,6 @@ }

var children = fs.readdirSync(dir);
var rendererJSFile;
for (var i=0, len=children.length; i<len; i++) {
rendererJSFile = null;
var childFilename = children[i];

@@ -276,2 +279,3 @@ if (childFilename === 'node_modules') {

var rendererFile = nodePath.join(dir, childFilename, 'renderer.js');
var indexFile = nodePath.join(dir, childFilename, 'index.js');
var templateFile = nodePath.join(dir, childFilename, 'template.marko');

@@ -290,2 +294,4 @@ var tagDef = null;

tagDef.renderer = rendererFile;
} else if (fs.existsSync(indexFile)) {
tagDef.renderer = indexFile;
} else if (fs.existsSync(templateFile)) {

@@ -308,12 +314,5 @@ tagDef.template = templateFile;

if (fs.existsSync(rendererFile)) {
var rendererCode = fs.readFileSync(rendererFile, {encoding: 'utf8'});
tagDef = tagDefFromCode.extractTagDef(rendererCode);
if (!tagDef) {
tagDef = createDefaultTagDef();
}
tagDef.renderer = rendererFile;
tag = buildTag(tagDef, tagsConfigPath, taglib, tagDirname);
tag.name = childFilename;
taglib.addTag(tag);
rendererJSFile = rendererFile;
} else if (fs.existsSync(indexFile)) {
rendererJSFile = indexFile;
} else {

@@ -338,2 +337,15 @@ var exTemplateFile;

if (rendererJSFile) {
var rendererCode = fs.readFileSync(rendererJSFile, {encoding: 'utf8'});
tagDef = tagDefFromCode.extractTagDef(rendererCode);
if (!tagDef) {
tagDef = createDefaultTagDef();
}
tagDef.renderer = rendererJSFile;
tag = buildTag(tagDef, tagsConfigPath, taglib, tagDirname);
tag.name = childFilename;
taglib.addTag(tag);
}
if (tagDef) {

@@ -340,0 +352,0 @@ tag = buildTag(tagDef, tagsConfigPath, taglib, tagDirname);

@@ -39,3 +39,2 @@ {

"raptor-regexp": "^1.0.0",
"raptor-renderer": "^1.1.10",
"raptor-strings": "^1.0.0",

@@ -63,3 +62,3 @@ "raptor-util": "^1.0.0",

},
"version": "1.6.1"
"version": "2.0.0"
}

@@ -91,2 +91,6 @@ var escapeXml = require('raptor-util/escapeXml');

as: attrs,
/**
* Loads a template
*/
l: function(path) {

@@ -106,28 +110,41 @@ if (typeof path === 'string') {

},
/**
* Returns the render function for a tag handler
*/
r: function(handler) {
var renderFunc;
if (typeof handler === 'function') {
renderFunc = handler;
} else {
renderFunc = handler.renderer || handler.render;
}
/* Helpers that require a context below: */
if (typeof renderFunc !== 'function') {
throw new Error('Invalid handler: ' + handler);
}
t: function (context, handler, props, body) {
if (!props) {
props = {};
return renderFunc;
},
// ----------------------------------
// Helpers that require an out below:
// ----------------------------------
/**
* Invoke a tag handler render function
*/
t: function (out, renderFunc, input, body) {
if (!input) {
input = {};
}
if (body) {
props.invokeBody = body;
input.invokeBody = body;
}
var func;
if (!(func = handler.process || handler.render)) {
if (typeof handler === 'function') {
func = handler;
} else {
throw new Error('Invalid handler: ' + handler);
}
}
func.call(handler, props, context);
renderFunc(input, out);
},
c: function (context, func) {
var output = context.captureString(func);
c: function (out, func) {
var output = out.captureString(func);
return {

@@ -139,3 +156,3 @@ toString: function () {

},
i: function(context, path, data) {
i: function(out, path, data) {
if (!path) {

@@ -146,5 +163,5 @@ return;

if (typeof path === 'string') {
runtime.render(path, data, context);
runtime.render(path, data, out);
} else if (typeof path.render === 'function') {
path.render(data, context);
path.render(data, out);
} else {

@@ -151,0 +168,0 @@ throw new Error('Invalid template');

@@ -191,22 +191,2 @@ /*

/**
* NOTE: This method can be removed in the very near future.
* It is only needed to make sure old templates that compiled
* to `module.exports = function(helpers) { ... }` will still
* load correctly even though new templates are compiled to
* `exports.create = function(helpers) { ... }`
*
*/
function wrapLegacyCompiledTemplate(loadedTemplate) {
if (typeof loadedTemplate === 'function') {
return {
create: function(helpers) {
return loadedTemplate(helpers);
}
};
}
return loadedTemplate;
}
function load(templatePath, options) {

@@ -230,3 +210,3 @@ var cache = exports.cache;

template = cache[templatePath] = new Template(
wrapLegacyCompiledTemplate(loader(templatePath)).create(helpers), // Load the template factory and invoke it
loader(templatePath).create(helpers), // Load the template factory and invoke it
options);

@@ -238,3 +218,3 @@ }

// used to get access to the compiled template function
template = templatePath._ || (templatePath._ = new Template(wrapLegacyCompiledTemplate(templatePath).create(helpers), options));
template = templatePath._ || (templatePath._ = new Template(templatePath.create(helpers), options));
}

@@ -241,0 +221,0 @@

@@ -388,5 +388,6 @@ /*

} else if (type === 'template') {
template.addStaticVar('__loadTemplate', '__helpers.l');
var templateVar;
if (compiler.hasExpression(attr.value)) {
value = compiler.makeExpression('__helpers.l(' +
value = compiler.makeExpression('__loadTemplate(' +
convertAttrValue(

@@ -399,3 +400,3 @@ attr,

// Resolve the static string to a full path only once
templateVar = template.addStaticVar(attr.value, '__helpers.l(require.resolve(' + compiler.convertType(attr.value, 'string', true) + '))');
templateVar = template.addStaticVar(attr.value, '__loadTemplate(require.resolve(' + compiler.convertType(attr.value, 'string', true) + '))');
value = compiler.makeExpression(templateVar);

@@ -411,3 +412,11 @@ }

// that are not declared (i.e. "*" attributes)
propName = attr.qName;
//
if (attrDef.preserveName === false) {
propName = removeDashes(attr.localName);
} else {
propName = attr.qName;
}
} else {

@@ -414,0 +423,0 @@ // Attributes map to properties and we allow the taglib

@@ -26,3 +26,3 @@ /*

handlerVar = renderer.replace(/[.\-\/\\]/g, '_').replace(/^[_]+/g, '');
handlerVar = template.addStaticVar(handlerVar, 'require(' + stringify(renderer) + ')');
handlerVar = template.addStaticVar(handlerVar, '__renderer(require(' + stringify(renderer) + '))');
handlerVars[renderer] = handlerVar;

@@ -105,5 +105,7 @@ }

doGenerateCode: function (template) {
template.addStaticVar('__renderer', '__helpers.r');
var rendererPath = template.getRequirePath(this.tag.renderer); // Resolve a path to the renderer relative to the directory of the template
var handlerVar = addHandlerVar(template, rendererPath);
var tagHelperVar = template.addStaticVar('_tag', '__helpers.t');
var tagHelperVar = template.addStaticVar('__tag', '__helpers.t');

@@ -110,0 +112,0 @@ this.tag.forEachImportedVariable(function (importedVariable) {

@@ -5,7 +5,8 @@ exports.create = function(__helpers) {

notEmpty = __helpers.ne,
hello_renderer = require("./hello-renderer"),
_tag = __helpers.t;
__renderer = __helpers.r,
hello_renderer = __renderer(require("./hello-renderer")),
__tag = __helpers.t;
return function render(data, out) {
_tag(out,
__tag(out,
hello_renderer,

@@ -12,0 +13,0 @@ {

@@ -1,3 +0,3 @@

exports.render = function(input, context) {
context.write('['+[
exports.render = function(input, out) {
out.write('['+[
input.prop1,

@@ -4,0 +4,0 @@ input.prop2,

@@ -1,5 +0,5 @@

exports.render = function(input, context) {
context.write("test: " + input.test + "|");
exports.render = function(input, out) {
out.write("test: " + input.test + "|");
var dynamicAttributes = input.dynamicAttributes;
if (dynamicAttributes) {

@@ -10,7 +10,7 @@ var keys = Object.keys(dynamicAttributes).sort();

});
context.write("dynamic attributes: [" + entries.join(", ") + "]");
out.write("dynamic attributes: [" + entries.join(", ") + "]");
}
else {
context.write("dynamic attributes: []");
out.write("dynamic attributes: []");
}
};

@@ -1,3 +0,3 @@

exports.render = function(input, context) {
context.write("test: " + input.test + "|");
exports.render = function(input, out) {
out.write("test: " + input.test + "|");
var dynamicAttributes = input['*'];

@@ -10,7 +10,7 @@

});
context.write("dynamic attributes: [" + entries.join(", ") + "]");
out.write("dynamic attributes: [" + entries.join(", ") + "]");
}
else {
context.write("dynamic attributes: []");
out.write("dynamic attributes: []");
}
};

@@ -1,3 +0,3 @@

exports.render = function(input, context) {
context.write("test: " + input.test + "|");
exports.render = function(input, out) {
out.write("test: " + input.test + "|");

@@ -8,3 +8,3 @@ var keys = Object.keys(input).sort();

});
context.write("all attributes: [" + entries.join(", ") + "]");
out.write("all attributes: [" + entries.join(", ") + "]");
};

@@ -1,3 +0,3 @@

exports.render = function(input, context) {
context.write('Hello ' + input.name + '!');
exports.render = function(input, out) {
out.write('Hello ' + input.name + '!');
};

@@ -1,3 +0,3 @@

exports.render = function(input, context) {
context.write('nested/a');
exports.render = function(input, out) {
out.write('nested/a');
};
var marko = require('../../');
exports.render = function(input, context) {
exports.render = function(input, out) {
marko.render(require.resolve('./popover.marko'), {

@@ -8,3 +8,3 @@ content: input.content,

tag: input
}, context);
}, out);
};

@@ -1,3 +0,3 @@

module.exports = function render(input, context) {
context.write('scanned-a: Hello ' + input.name);
module.exports = function render(input, out) {
out.write('scanned-a: Hello ' + input.name);
};

@@ -1,3 +0,3 @@

module.exports = function render(input, context) {
context.write('scanned-c: Hello ' + input.NAME);
module.exports = function render(input, out) {
out.write('scanned-c: Hello ' + input.NAME);
};

@@ -10,4 +10,4 @@ exports.TAG = {

module.exports = function render(input, context) {
context.write('scanned-e: Hello ' + input.NAME);
module.exports = function render(input, out) {
out.write('scanned-e: Hello ' + input.NAME);
};

@@ -12,4 +12,4 @@ /*

module.exports = function render(input, context) {
context.write('scanned-f: Hello ' + input.NAME);
module.exports = function render(input, out) {
out.write('scanned-f: Hello ' + input.NAME);
};

@@ -1,4 +0,4 @@

exports.process = function(input, context) {
exports.render = function(input, out) {
var name = input.name || "(unknown)";
context.write("Hello " + name + "! adult=" + (input.adult === true));
out.write("Hello " + name + "! adult=" + (input.adult === true));
};

@@ -1,4 +0,4 @@

exports.render = function(input, context) {
exports.render = function(input, out) {
var tabs = input.tabs;
tabs.addTab(input);
};
var marko = require('../../');
exports.render = function(input, context) {
exports.render = function(input, out) {
var tabs = [],

@@ -29,4 +29,4 @@ activeFound = false;

tabs: tabs
}, context);
}, out);
};

@@ -5,4 +5,4 @@ exports.create = function(__helpers) {

return function render(data, context) {
context.w(('\nA: ') +
return function render(data, out) {
out.w(('\nA: ') +
(true ? 'ABC' : '') +

@@ -9,0 +9,0 @@ ('\nB: This should be outputted as well.\n'));

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc