Fixes #52 Remove JavaScript comments from JSON taglib files before parsing

This commit is contained in:
Patrick Steele-Idem 2015-03-20 13:01:41 -06:00
parent b7fc101663
commit 553a284233
2 changed files with 65 additions and 63 deletions

View File

@ -16,6 +16,7 @@ var raptorRegexp = require('raptor-regexp');
var tagDefFromCode = require('./tag-def-from-code'); var tagDefFromCode = require('./tag-def-from-code');
var resolve = require('../util/resolve'); // NOTE: different implementation for browser var resolve = require('../util/resolve'); // NOTE: different implementation for browser
var propertyHandlers = require('property-handlers'); var propertyHandlers = require('property-handlers');
var jsonminify = require('jsonminify');
var safeVarName = /^[A-Za-z_$][A-Za-z0-9_]*$/; var safeVarName = /^[A-Za-z_$][A-Za-z0-9_]*$/;
var bodyFunctionRegExp = /^([A-Za-z_$][A-Za-z0-9_]*)(?:\(([^)]*)\))?$/; var bodyFunctionRegExp = /^([A-Za-z_$][A-Za-z0-9_]*)(?:\(([^)]*)\))?$/;
@ -218,7 +219,7 @@ function buildTag(tagObject, path, taglib, dirname) {
tag.setBodyFunction(functionName, params); tag.setBodyFunction(functionName, params);
}, },
bodyProperty: function(value) { bodyProperty: function(value) {
tag.setBodyProperty(value) tag.setBodyProperty(value);
}, },
vars: function(value) { vars: function(value) {
if (value) { if (value) {
@ -326,7 +327,7 @@ function scanTagsDir(tagsConfigPath, tagsConfigDirname, dir, taglib) {
if (fs.existsSync(tagFile)) { if (fs.existsSync(tagFile)) {
// marko-tag.json exists in the directory, use that as the tag definition // marko-tag.json exists in the directory, use that as the tag definition
tagDef = JSON.parse(fs.readFileSync(tagFile, {encoding: 'utf8'})); tagDef = JSON.parse(jsonminify(fs.readFileSync(tagFile, {encoding: 'utf8'})));
if (!tagDef.renderer && !tagDef.template) { if (!tagDef.renderer && !tagDef.template) {
if (fs.existsSync(rendererFile)) { if (fs.existsSync(rendererFile)) {
tagDef.renderer = rendererFile; tagDef.renderer = rendererFile;

View File

@ -1,62 +1,63 @@
{ {
"name": "marko", "name": "marko",
"description": "Marko is an extensible, streaming, asynchronous, high performance, HTML-based templating language that can be used in Node.js or in the browser.", "description": "Marko is an extensible, streaming, asynchronous, high performance, HTML-based templating language that can be used in Node.js or in the browser.",
"keywords": [ "keywords": [
"templating", "templating",
"template", "template",
"async", "async",
"streaming" "streaming"
], ],
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/raptorjs/marko.git" "url": "https://github.com/raptorjs/marko.git"
}, },
"scripts": { "scripts": {
"test": "node_modules/.bin/mocha --ui bdd --reporter spec ./test && node_modules/.bin/jshint compiler/ runtime/ taglibs/" "test": "node_modules/.bin/mocha --ui bdd --reporter spec ./test && node_modules/.bin/jshint compiler/ runtime/ taglibs/"
}, },
"author": "Patrick Steele-Idem <pnidem@gmail.com>", "author": "Patrick Steele-Idem <pnidem@gmail.com>",
"maintainers": [ "maintainers": [
"Patrick Steele-Idem <pnidem@gmail.com>" "Patrick Steele-Idem <pnidem@gmail.com>"
], ],
"dependencies": { "dependencies": {
"app-module-path": "^1.0.0", "app-module-path": "^1.0.0",
"async-writer": "^1.1.2", "async-writer": "^1.1.2",
"browser-refresh-client": "^1.0.0", "browser-refresh-client": "^1.0.0",
"char-props": "~0.1.5", "char-props": "~0.1.5",
"events": "^1.0.2", "events": "^1.0.2",
"htmlparser2": "^3.7.2", "htmlparser2": "^3.7.2",
"marko-async": "^2.0.0", "jsonminify": "^0.2.3",
"marko-layout": "^2.0.0", "marko-async": "^2.0.0",
"minimatch": "^0.2.14", "marko-layout": "^2.0.0",
"property-handlers": "^1.0.0", "minimatch": "^0.2.14",
"raptor-args": "^1.0.0", "property-handlers": "^1.0.0",
"raptor-json": "^1.0.1", "raptor-args": "^1.0.0",
"raptor-logging": "^1.0.1", "raptor-json": "^1.0.1",
"raptor-modules": "^1.0.5", "raptor-logging": "^1.0.1",
"raptor-polyfill": "^1.0.0", "raptor-modules": "^1.0.5",
"raptor-promises": "^1.0.1", "raptor-polyfill": "^1.0.0",
"raptor-regexp": "^1.0.0", "raptor-promises": "^1.0.1",
"raptor-strings": "^1.0.0", "raptor-regexp": "^1.0.0",
"raptor-util": "^1.0.0", "raptor-strings": "^1.0.0",
"resolve-from": "^1.0.0", "raptor-util": "^1.0.0",
"sax": "^0.6.0" "resolve-from": "^1.0.0",
}, "sax": "^0.6.0"
"devDependencies": { },
"chai": "~1.8.1", "devDependencies": {
"dustjs-linkedin": "^2.3.4", "chai": "~1.8.1",
"jshint": "^2.5.0", "dustjs-linkedin": "^2.3.4",
"mocha": "~1.15.1", "jshint": "^2.5.0",
"raptor-cache": "^1.1.1", "mocha": "~1.15.1",
"raptor-data-providers": "^1.0.1-beta", "raptor-cache": "^1.1.1",
"through": "^2.3.4" "raptor-data-providers": "^1.0.1-beta",
}, "through": "^2.3.4"
"license": "Apache License v2.0", },
"bin": { "license": "Apache License v2.0",
"markoc": "bin/markoc" "bin": {
}, "markoc": "bin/markoc"
"main": "runtime/marko-runtime.js", },
"publishConfig": { "main": "runtime/marko-runtime.js",
"registry": "https://registry.npmjs.org/" "publishConfig": {
}, "registry": "https://registry.npmjs.org/"
"version": "2.1.6" },
} "version": "2.1.6"
}