marko 2.11.1 → 2.11.3
Sign up to get free protection for your applications and to get access to all the features.
- package/compiler/TemplateBuilder.js +1 -1
- package/compiler/TypeConverter.js +1 -1
- package/compiler/expression-parser.js +1 -1
- package/compiler/util/stringify.js +169 -0
- package/package.json +2 -3
- package/taglibs/core/ForNode.js +1 -1
- package/taglibs/core/IncludeNode.js +1 -1
- package/taglibs/core/TagHandlerNode.js +1 -1
- package/.npmignore +0 -1
- package/coverage/coverage.json +0 -1
- package/coverage/lcov-report/base.css +0 -213
- package/coverage/lcov-report/index.html +0 -496
- package/coverage/lcov-report/marko-v4/bin/index.html +0 -93
- package/coverage/lcov-report/marko-v4/bin/markoc.js.html +0 -1160
- package/coverage/lcov-report/marko-v4/browser-refresh/index.html +0 -93
- package/coverage/lcov-report/marko-v4/browser-refresh/index.js.html +0 -191
- package/coverage/lcov-report/marko-v4/compiler/Builder.js.html +0 -1859
- package/coverage/lcov-report/marko-v4/compiler/CodeGenerator.js.html +0 -998
- package/coverage/lcov-report/marko-v4/compiler/CodeWriter.js.html +0 -851
- package/coverage/lcov-report/marko-v4/compiler/CompileContext.js.html +0 -1955
- package/coverage/lcov-report/marko-v4/compiler/CompileError.js.html +0 -206
- package/coverage/lcov-report/marko-v4/compiler/Compiler.js.html +0 -473
- package/coverage/lcov-report/marko-v4/compiler/HtmlJsParser.js.html +0 -341
- package/coverage/lcov-report/marko-v4/compiler/InlineCompiler.js.html +0 -317
- package/coverage/lcov-report/marko-v4/compiler/Parser.js.html +0 -1271
- package/coverage/lcov-report/marko-v4/compiler/Walker.js.html +0 -521
- package/coverage/lcov-report/marko-v4/compiler/ast/ArrayContainer.js.html +0 -653
- package/coverage/lcov-report/marko-v4/compiler/ast/ArrayExpression.js.html +0 -278
- package/coverage/lcov-report/marko-v4/compiler/ast/Assignment.js.html +0 -299
- package/coverage/lcov-report/marko-v4/compiler/ast/AttributePlaceholder.js.html +0 -173
- package/coverage/lcov-report/marko-v4/compiler/ast/BinaryExpression.js.html +0 -428
- package/coverage/lcov-report/marko-v4/compiler/ast/Code.js.html +0 -149
- package/coverage/lcov-report/marko-v4/compiler/ast/ConditionalExpression.js.html +0 -239
- package/coverage/lcov-report/marko-v4/compiler/ast/Container.js.html +0 -101
- package/coverage/lcov-report/marko-v4/compiler/ast/ContainerNode.js.html +0 -122
- package/coverage/lcov-report/marko-v4/compiler/ast/CustomTag.js.html +0 -1250
- package/coverage/lcov-report/marko-v4/compiler/ast/Declaration.js.html +0 -146
- package/coverage/lcov-report/marko-v4/compiler/ast/DocumentType.js.html +0 -146
- package/coverage/lcov-report/marko-v4/compiler/ast/Else.js.html +0 -161
- package/coverage/lcov-report/marko-v4/compiler/ast/ElseIf.js.html +0 -152
- package/coverage/lcov-report/marko-v4/compiler/ast/Expression.js.html +0 -152
- package/coverage/lcov-report/marko-v4/compiler/ast/ForEach.js.html +0 -314
- package/coverage/lcov-report/marko-v4/compiler/ast/ForEachProp.js.html +0 -290
- package/coverage/lcov-report/marko-v4/compiler/ast/ForRange.js.html +0 -374
- package/coverage/lcov-report/marko-v4/compiler/ast/ForStatement.js.html +0 -245
- package/coverage/lcov-report/marko-v4/compiler/ast/FunctionCall.js.html +0 -374
- package/coverage/lcov-report/marko-v4/compiler/ast/FunctionDeclaration.js.html +0 -296
- package/coverage/lcov-report/marko-v4/compiler/ast/Html.js.html +0 -311
- package/coverage/lcov-report/marko-v4/compiler/ast/HtmlAttribute/html/generateCode.js.html +0 -473
- package/coverage/lcov-report/marko-v4/compiler/ast/HtmlAttribute/html/index.html +0 -93
- package/coverage/lcov-report/marko-v4/compiler/ast/HtmlAttribute/index.html +0 -93
- package/coverage/lcov-report/marko-v4/compiler/ast/HtmlAttribute/index.js.html +0 -317
- package/coverage/lcov-report/marko-v4/compiler/ast/HtmlAttribute/vdom/generateCode.js.html +0 -128
- package/coverage/lcov-report/marko-v4/compiler/ast/HtmlAttribute/vdom/index.html +0 -93
- package/coverage/lcov-report/marko-v4/compiler/ast/HtmlAttributeCollection.js.html +0 -521
- package/coverage/lcov-report/marko-v4/compiler/ast/HtmlComment.js.html +0 -182
- package/coverage/lcov-report/marko-v4/compiler/ast/HtmlElement/html/EndTag.js.html +0 -131
- package/coverage/lcov-report/marko-v4/compiler/ast/HtmlElement/html/StartTag.js.html +0 -227
- package/coverage/lcov-report/marko-v4/compiler/ast/HtmlElement/html/generateCode.js.html +0 -299
- package/coverage/lcov-report/marko-v4/compiler/ast/HtmlElement/html/index.html +0 -119
- package/coverage/lcov-report/marko-v4/compiler/ast/HtmlElement/index.html +0 -93
- package/coverage/lcov-report/marko-v4/compiler/ast/HtmlElement/index.js.html +0 -578
- package/coverage/lcov-report/marko-v4/compiler/ast/HtmlElement/vdom/EndElementVDOM.js.html +0 -104
- package/coverage/lcov-report/marko-v4/compiler/ast/HtmlElement/vdom/HtmlElementVDOM.js.html +0 -620
- package/coverage/lcov-report/marko-v4/compiler/ast/HtmlElement/vdom/generateCode.js.html +0 -326
- package/coverage/lcov-report/marko-v4/compiler/ast/HtmlElement/vdom/index.html +0 -119
- package/coverage/lcov-report/marko-v4/compiler/ast/Identifier.js.html +0 -137
- package/coverage/lcov-report/marko-v4/compiler/ast/If.js.html +0 -347
- package/coverage/lcov-report/marko-v4/compiler/ast/InvokeMacro.js.html +0 -425
- package/coverage/lcov-report/marko-v4/compiler/ast/Literal.js.html +0 -320
- package/coverage/lcov-report/marko-v4/compiler/ast/LogicalExpression.js.html +0 -359
- package/coverage/lcov-report/marko-v4/compiler/ast/Macro.js.html +0 -176
- package/coverage/lcov-report/marko-v4/compiler/ast/MemberExpression.js.html +0 -308
- package/coverage/lcov-report/marko-v4/compiler/ast/NewExpression.js.html +0 -395
- package/coverage/lcov-report/marko-v4/compiler/ast/Node.js.html +0 -1235
- package/coverage/lcov-report/marko-v4/compiler/ast/ObjectExpression.js.html +0 -290
- package/coverage/lcov-report/marko-v4/compiler/ast/Program.js.html +0 -134
- package/coverage/lcov-report/marko-v4/compiler/ast/Property.js.html +0 -257
- package/coverage/lcov-report/marko-v4/compiler/ast/Return.js.html +0 -170
- package/coverage/lcov-report/marko-v4/compiler/ast/Scriptlet.js.html +0 -152
- package/coverage/lcov-report/marko-v4/compiler/ast/SelfInvokingFunction.js.html +0 -155
- package/coverage/lcov-report/marko-v4/compiler/ast/TemplateRoot.js.html +0 -344
- package/coverage/lcov-report/marko-v4/compiler/ast/Text/html/generateCode.js.html +0 -245
- package/coverage/lcov-report/marko-v4/compiler/ast/Text/html/index.html +0 -93
- package/coverage/lcov-report/marko-v4/compiler/ast/Text/index.html +0 -93
- package/coverage/lcov-report/marko-v4/compiler/ast/Text/index.js.html +0 -215
- package/coverage/lcov-report/marko-v4/compiler/ast/Text/vdom/TextVDOM.js.html +0 -407
- package/coverage/lcov-report/marko-v4/compiler/ast/Text/vdom/generateCode.js.html +0 -179
- package/coverage/lcov-report/marko-v4/compiler/ast/Text/vdom/index.html +0 -106
- package/coverage/lcov-report/marko-v4/compiler/ast/ThisExpression.js.html +0 -131
- package/coverage/lcov-report/marko-v4/compiler/ast/UnaryExpression.js.html +0 -365
- package/coverage/lcov-report/marko-v4/compiler/ast/UpdateExpression.js.html +0 -341
- package/coverage/lcov-report/marko-v4/compiler/ast/VariableDeclarator.js.html +0 -221
- package/coverage/lcov-report/marko-v4/compiler/ast/Vars.js.html +0 -290
- package/coverage/lcov-report/marko-v4/compiler/ast/WhileStatement.js.html +0 -173
- package/coverage/lcov-report/marko-v4/compiler/ast/index.html +0 -678
- package/coverage/lcov-report/marko-v4/compiler/config.js.html +0 -194
- package/coverage/lcov-report/marko-v4/compiler/index.html +0 -236
- package/coverage/lcov-report/marko-v4/compiler/index.js.html +0 -695
- package/coverage/lcov-report/marko-v4/compiler/taglib-finder/index-browser.js.html +0 -158
- package/coverage/lcov-report/marko-v4/compiler/taglib-finder/index.html +0 -106
- package/coverage/lcov-report/marko-v4/compiler/taglib-finder/index.js.html +0 -632
- package/coverage/lcov-report/marko-v4/compiler/taglib-loader/DependencyChain.js.html +0 -113
- package/coverage/lcov-report/marko-v4/compiler/taglib-loader/Taglib/Attribute.js.html +0 -155
- package/coverage/lcov-report/marko-v4/compiler/taglib-loader/Taglib/ImportedVariable.js.html +0 -140
- package/coverage/lcov-report/marko-v4/compiler/taglib-loader/Taglib/NestedVariable.js.html +0 -134
- package/coverage/lcov-report/marko-v4/compiler/taglib-loader/Taglib/Property.js.html +0 -140
- package/coverage/lcov-report/marko-v4/compiler/taglib-loader/Taglib/Tag.js.html +0 -797
- package/coverage/lcov-report/marko-v4/compiler/taglib-loader/Taglib/Taglib.js.html +0 -440
- package/coverage/lcov-report/marko-v4/compiler/taglib-loader/Taglib/Transformer.js.html +0 -236
- package/coverage/lcov-report/marko-v4/compiler/taglib-loader/Taglib/index.html +0 -184
- package/coverage/lcov-report/marko-v4/compiler/taglib-loader/Taglib/index.js.html +0 -65
- package/coverage/lcov-report/marko-v4/compiler/taglib-loader/handleAttributes.js.html +0 -161
- package/coverage/lcov-report/marko-v4/compiler/taglib-loader/index.html +0 -236
- package/coverage/lcov-report/marko-v4/compiler/taglib-loader/index.js.html +0 -191
- package/coverage/lcov-report/marko-v4/compiler/taglib-loader/json-file-reader-browser.js.html +0 -143
- package/coverage/lcov-report/marko-v4/compiler/taglib-loader/json-file-reader.js.html +0 -155
- package/coverage/lcov-report/marko-v4/compiler/taglib-loader/loader-attribute.js.html +0 -659
- package/coverage/lcov-report/marko-v4/compiler/taglib-loader/loader-tag.js.html +0 -1931
- package/coverage/lcov-report/marko-v4/compiler/taglib-loader/loader-taglib.js.html +0 -1010
- package/coverage/lcov-report/marko-v4/compiler/taglib-loader/loader.js.html +0 -119
- package/coverage/lcov-report/marko-v4/compiler/taglib-loader/scanTagsDir-browser.js.html +0 -119
- package/coverage/lcov-report/marko-v4/compiler/taglib-loader/scanTagsDir.js.html +0 -548
- package/coverage/lcov-report/marko-v4/compiler/taglib-loader/tag-def-from-code.js.html +0 -287
- package/coverage/lcov-report/marko-v4/compiler/taglib-lookup/TaglibLookup.js.html +0 -1205
- package/coverage/lcov-report/marko-v4/compiler/taglib-lookup/index.html +0 -106
- package/coverage/lcov-report/marko-v4/compiler/taglib-lookup/index.js.html +0 -302
- package/coverage/lcov-report/marko-v4/compiler/util/PosInfo.js.html +0 -140
- package/coverage/lcov-report/marko-v4/compiler/util/UniqueVars.js.html +0 -227
- package/coverage/lcov-report/marko-v4/compiler/util/adjustIndent.js.html +0 -272
- package/coverage/lcov-report/marko-v4/compiler/util/deresolve-browser.js.html +0 -119
- package/coverage/lcov-report/marko-v4/compiler/util/deresolve.js.html +0 -113
- package/coverage/lcov-report/marko-v4/compiler/util/fingerprint.js.html +0 -83
- package/coverage/lcov-report/marko-v4/compiler/util/index.html +0 -366
- package/coverage/lcov-report/marko-v4/compiler/util/isCompoundExpression.js.html +0 -92
- package/coverage/lcov-report/marko-v4/compiler/util/isJavaScriptReservedWord.js.html +0 -80
- package/coverage/lcov-report/marko-v4/compiler/util/isValidJavaScriptIdentifier.js.html +0 -80
- package/coverage/lcov-report/marko-v4/compiler/util/isValidJavaScriptVarName.js.html +0 -95
- package/coverage/lcov-report/marko-v4/compiler/util/javaScriptReservedWords.js.html +0 -260
- package/coverage/lcov-report/marko-v4/compiler/util/macros.js.html +0 -326
- package/coverage/lcov-report/marko-v4/compiler/util/parseExpression.js.html +0 -77
- package/coverage/lcov-report/marko-v4/compiler/util/parseJavaScript.js.html +0 -833
- package/coverage/lcov-report/marko-v4/compiler/util/parseJavaScriptArgs.js.html +0 -101
- package/coverage/lcov-report/marko-v4/compiler/util/parseStatement.js.html +0 -77
- package/coverage/lcov-report/marko-v4/compiler/util/removeComments.js.html +0 -221
- package/coverage/lcov-report/marko-v4/compiler/util/removeDashes.js.html +0 -77
- package/coverage/lcov-report/marko-v4/compiler/util/resolve-browser.js.html +0 -125
- package/coverage/lcov-report/marko-v4/compiler/util/resolve.js.html +0 -128
- package/coverage/lcov-report/marko-v4/compiler/util/safeVarName.js.html +0 -116
- package/coverage/lcov-report/marko-v4/compiler/util/tokenizer.js.html +0 -173
- package/coverage/lcov-report/marko-v4/compiler/util/vdom/VDOMOptimizer.js.html +0 -560
- package/coverage/lcov-report/marko-v4/compiler/util/vdom/index.html +0 -119
- package/coverage/lcov-report/marko-v4/compiler/util/vdom/index.js.html +0 -119
- package/coverage/lcov-report/marko-v4/compiler/util/vdom/isStaticValue.js.html +0 -212
- package/coverage/lcov-report/marko-v4/defineRenderer.js.html +0 -206
- package/coverage/lcov-report/marko-v4/express.js.html +0 -161
- package/coverage/lcov-report/marko-v4/helpers/empty.js.html +0 -77
- package/coverage/lcov-report/marko-v4/helpers/index.html +0 -106
- package/coverage/lcov-report/marko-v4/helpers/notEmpty.js.html +0 -95
- package/coverage/lcov-report/marko-v4/hot-reload/index.html +0 -93
- package/coverage/lcov-report/marko-v4/hot-reload/index.js.html +0 -524
- package/coverage/lcov-report/marko-v4/index.html +0 -158
- package/coverage/lcov-report/marko-v4/node-require-browser.js.html +0 -113
- package/coverage/lcov-report/marko-v4/node-require.js.html +0 -434
- package/coverage/lcov-report/marko-v4/runtime/deprecate.js.html +0 -131
- package/coverage/lcov-report/marko-v4/runtime/forEachPropStatusVar.js.html +0 -158
- package/coverage/lcov-report/marko-v4/runtime/helpers.js.html +0 -839
- package/coverage/lcov-report/marko-v4/runtime/html/helpers.js.html +0 -506
- package/coverage/lcov-report/marko-v4/runtime/html/index.html +0 -106
- package/coverage/lcov-report/marko-v4/runtime/html/index.js.html +0 -914
- package/coverage/lcov-report/marko-v4/runtime/index.html +0 -145
- package/coverage/lcov-report/marko-v4/runtime/inline.js.html +0 -65
- package/coverage/lcov-report/marko-v4/runtime/loader/index-browser-dynamic.js.html +0 -128
- package/coverage/lcov-report/marko-v4/runtime/loader/index-browser.js.html +0 -119
- package/coverage/lcov-report/marko-v4/runtime/loader/index.html +0 -119
- package/coverage/lcov-report/marko-v4/runtime/loader/index.js.html +0 -548
- package/coverage/lcov-report/marko-v4/runtime/stream.js.html +0 -224
- package/coverage/lcov-report/marko-v4/runtime/vdom/helpers.js.html +0 -350
- package/coverage/lcov-report/marko-v4/runtime/vdom/index.html +0 -106
- package/coverage/lcov-report/marko-v4/runtime/vdom/index.js.html +0 -893
- package/coverage/lcov-report/marko-v4/stream.js.html +0 -98
- package/coverage/lcov-report/marko-v4/taglibs/async/async-fragment-to-await-transformer.js.html +0 -221
- package/coverage/lcov-report/marko-v4/taglibs/async/await-nested-tag-transformer.js.html +0 -140
- package/coverage/lcov-report/marko-v4/taglibs/async/await-reorderer-tag.js.html +0 -278
- package/coverage/lcov-report/marko-v4/taglibs/async/await-tag-transformer.js.html +0 -353
- package/coverage/lcov-report/marko-v4/taglibs/async/await-tag.js.html +0 -779
- package/coverage/lcov-report/marko-v4/taglibs/async/client-reorder-browser.js.html +0 -65
- package/coverage/lcov-report/marko-v4/taglibs/async/client-reorder-runtime.js.html +0 -167
- package/coverage/lcov-report/marko-v4/taglibs/async/client-reorder-runtime.min.js.html +0 -65
- package/coverage/lcov-report/marko-v4/taglibs/async/client-reorder.js.html +0 -98
- package/coverage/lcov-report/marko-v4/taglibs/async/index.html +0 -197
- package/coverage/lcov-report/marko-v4/taglibs/cache/cached-fragment-tag-transformer.js.html +0 -89
- package/coverage/lcov-report/marko-v4/taglibs/cache/cached-fragment-tag.js.html +0 -266
- package/coverage/lcov-report/marko-v4/taglibs/cache/default-cache-manager.js.html +0 -173
- package/coverage/lcov-report/marko-v4/taglibs/cache/index.html +0 -119
- package/coverage/lcov-report/marko-v4/taglibs/core/assign-tag.js.html +0 -116
- package/coverage/lcov-report/marko-v4/taglibs/core/core-transformer.js.html +0 -683
- package/coverage/lcov-report/marko-v4/taglibs/core/else-if-tag.js.html +0 -140
- package/coverage/lcov-report/marko-v4/taglibs/core/else-tag.js.html +0 -170
- package/coverage/lcov-report/marko-v4/taglibs/core/for-tag.js.html +0 -131
- package/coverage/lcov-report/marko-v4/taglibs/core/if-tag.js.html +0 -140
- package/coverage/lcov-report/marko-v4/taglibs/core/include-html-tag-browser.js.html +0 -113
- package/coverage/lcov-report/marko-v4/taglibs/core/include-html-tag.js.html +0 -152
- package/coverage/lcov-report/marko-v4/taglibs/core/include-tag.js.html +0 -248
- package/coverage/lcov-report/marko-v4/taglibs/core/include-text-tag-browser.js.html +0 -113
- package/coverage/lcov-report/marko-v4/taglibs/core/include-text-tag.js.html +0 -152
- package/coverage/lcov-report/marko-v4/taglibs/core/index.html +0 -314
- package/coverage/lcov-report/marko-v4/taglibs/core/invoke-tag.js.html +0 -116
- package/coverage/lcov-report/marko-v4/taglibs/core/macro-body-tag.js.html +0 -83
- package/coverage/lcov-report/marko-v4/taglibs/core/macro-tag.js.html +0 -131
- package/coverage/lcov-report/marko-v4/taglibs/core/marko-preserve-whitespace-tag.js.html +0 -71
- package/coverage/lcov-report/marko-v4/taglibs/core/unless-tag.js.html +0 -143
- package/coverage/lcov-report/marko-v4/taglibs/core/util/createLoopNode.js.html +0 -128
- package/coverage/lcov-report/marko-v4/taglibs/core/util/index.html +0 -119
- package/coverage/lcov-report/marko-v4/taglibs/core/util/parseFor.js.html +0 -1145
- package/coverage/lcov-report/marko-v4/taglibs/core/util/parseJavaScriptIdentifier.js.html +0 -131
- package/coverage/lcov-report/marko-v4/taglibs/core/var-tag.js.html +0 -152
- package/coverage/lcov-report/marko-v4/taglibs/core/while-tag.js.html +0 -95
- package/coverage/lcov-report/marko-v4/taglibs/html/html-comment-tag.js.html +0 -146
- package/coverage/lcov-report/marko-v4/taglibs/html/index.html +0 -93
- package/coverage/lcov-report/marko-v4/taglibs/layout/index.html +0 -132
- package/coverage/lcov-report/marko-v4/taglibs/layout/placeholder-tag.js.html +0 -107
- package/coverage/lcov-report/marko-v4/taglibs/layout/put-tag.js.html +0 -77
- package/coverage/lcov-report/marko-v4/taglibs/layout/use-tag-transformer.js.html +0 -137
- package/coverage/lcov-report/marko-v4/taglibs/layout/use-tag.js.html +0 -134
- package/coverage/lcov-report/marko-v4/vdom.js.html +0 -65
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -1
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -158
- package/coverage/lcov.info +0 -13662
@@ -16,7 +16,7 @@
|
|
16
16
|
'use strict';
|
17
17
|
var createError = require('raptor-util').createError;
|
18
18
|
var nodePath = require('path');
|
19
|
-
var stringify = require('
|
19
|
+
var stringify = require('./util/stringify');
|
20
20
|
var StringBuilder = require('raptor-strings/StringBuilder');
|
21
21
|
var Expression = require('./Expression');
|
22
22
|
var arrayFromArguments = require('raptor-util').arrayFromArguments;
|
@@ -16,7 +16,7 @@
|
|
16
16
|
'use strict';
|
17
17
|
var createError = require('raptor-util').createError;
|
18
18
|
var expressionParser = require('./expression-parser');
|
19
|
-
var stringify = require('
|
19
|
+
var stringify = require('./util/stringify');
|
20
20
|
var Expression = require('./Expression');
|
21
21
|
function TypeConverter() {
|
22
22
|
}
|
@@ -17,7 +17,7 @@
|
|
17
17
|
var createError = require('raptor-util').createError;
|
18
18
|
var Expression = require('./Expression');
|
19
19
|
var strings = require('raptor-strings');
|
20
|
-
var stringify = require('
|
20
|
+
var stringify = require('./util/stringify');
|
21
21
|
var regexp = require('raptor-regexp');
|
22
22
|
var ok = require('assert').ok;
|
23
23
|
|
@@ -0,0 +1,169 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright 2011 eBay Software Foundation
|
3
|
+
*
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
* you may not use this file except in compliance with the License.
|
6
|
+
* You may obtain a copy of the License at
|
7
|
+
*
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
*
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
* See the License for the specific language governing permissions and
|
14
|
+
* limitations under the License.
|
15
|
+
*/
|
16
|
+
|
17
|
+
/**
|
18
|
+
* Defines a "stringify" function that can be pulled in using require.
|
19
|
+
*
|
20
|
+
* Example:
|
21
|
+
* <js>
|
22
|
+
* var stringify = require('raptor/json/stringify');
|
23
|
+
* var json = stringify({hello: "world"});
|
24
|
+
* //Output: {"hello":"world"}
|
25
|
+
* </js>
|
26
|
+
*
|
27
|
+
* The Raptor stringify function supports additional options not provided
|
28
|
+
* by the builtin JSON object:
|
29
|
+
* <b>special</b>: A regular expression to indicate "special" characters that must be escaped
|
30
|
+
* <b>useSingleQuote</b>: If true, then single quotes will be used for strings instead of double quotes (helpful if the the string values contain a lot of double quotes)
|
31
|
+
*
|
32
|
+
*/
|
33
|
+
|
34
|
+
var raptorStrings = require("raptor-strings");
|
35
|
+
var unicodeEncode = raptorStrings.unicodeEncode; //Pick up the unicodeEncode method from the strings module
|
36
|
+
var COMMA = ",";
|
37
|
+
var NULL = "null";
|
38
|
+
var ARRAY = Array;
|
39
|
+
var SPECIAL = /([^ -~]|(["'\\]))/g;
|
40
|
+
var REPLACE_CHARS = {
|
41
|
+
"\b": "\\b",
|
42
|
+
"\t": "\\t",
|
43
|
+
"\n": "\\n",
|
44
|
+
"\f": "\\f",
|
45
|
+
"\r": "\\r",
|
46
|
+
"\\": "\\\\",
|
47
|
+
};
|
48
|
+
|
49
|
+
function stringify(o, options) {
|
50
|
+
if (!options) {
|
51
|
+
options = {};
|
52
|
+
}
|
53
|
+
|
54
|
+
var specialRegExp = options.special || SPECIAL;
|
55
|
+
var replace = options.replace || REPLACE_CHARS;
|
56
|
+
|
57
|
+
var buffer = raptorStrings.createStringBuilder();
|
58
|
+
|
59
|
+
function append(str) {
|
60
|
+
buffer.append(str);
|
61
|
+
}
|
62
|
+
|
63
|
+
var useSingleQuote = options.useSingleQuote === true;
|
64
|
+
var strChar = useSingleQuote === true ? "'" : '"';
|
65
|
+
function encodeString(s) {
|
66
|
+
return (
|
67
|
+
strChar +
|
68
|
+
s.replace(specialRegExp, function (c) {
|
69
|
+
var replacement = replace[c];
|
70
|
+
|
71
|
+
if (replacement) {
|
72
|
+
return replacement;
|
73
|
+
}
|
74
|
+
|
75
|
+
if (c === '"') {
|
76
|
+
return useSingleQuote ? '"' : '\\"';
|
77
|
+
} else if (c === "'") {
|
78
|
+
return useSingleQuote ? "\\'" : "'";
|
79
|
+
} else {
|
80
|
+
return unicodeEncode(c);
|
81
|
+
}
|
82
|
+
}) +
|
83
|
+
strChar
|
84
|
+
);
|
85
|
+
}
|
86
|
+
|
87
|
+
function serialize(o) {
|
88
|
+
if (o == null) {
|
89
|
+
append(NULL);
|
90
|
+
return;
|
91
|
+
}
|
92
|
+
|
93
|
+
var constr = o.constructor,
|
94
|
+
i,
|
95
|
+
len;
|
96
|
+
|
97
|
+
if (typeof o.toJSON === "function") {
|
98
|
+
if (constr !== Date) {
|
99
|
+
// Dates are handled later
|
100
|
+
o = o.toJSON();
|
101
|
+
if (o == null) {
|
102
|
+
append(NULL);
|
103
|
+
return;
|
104
|
+
}
|
105
|
+
|
106
|
+
constr = o.constructor;
|
107
|
+
}
|
108
|
+
}
|
109
|
+
|
110
|
+
if (o === true || o === false || constr === Boolean) {
|
111
|
+
append(o.toString());
|
112
|
+
} else if (constr === ARRAY) {
|
113
|
+
append("[");
|
114
|
+
|
115
|
+
len = o.length;
|
116
|
+
for (i = 0; i < len; i++) {
|
117
|
+
if (i !== 0) {
|
118
|
+
append(COMMA);
|
119
|
+
}
|
120
|
+
|
121
|
+
serialize(o[i]);
|
122
|
+
}
|
123
|
+
|
124
|
+
append("]");
|
125
|
+
} else if (constr === Date) {
|
126
|
+
append(o.getTime());
|
127
|
+
} else {
|
128
|
+
var type = typeof o;
|
129
|
+
switch (type) {
|
130
|
+
case "string":
|
131
|
+
append(encodeString(o));
|
132
|
+
break;
|
133
|
+
case "number":
|
134
|
+
append(isFinite(o) ? o + "" : NULL);
|
135
|
+
break;
|
136
|
+
case "object":
|
137
|
+
append("{");
|
138
|
+
var first = true,
|
139
|
+
v;
|
140
|
+
for (var k in o) {
|
141
|
+
if (o.hasOwnProperty(k)) {
|
142
|
+
v = o[k];
|
143
|
+
if (v == null || typeof v === "function") continue;
|
144
|
+
|
145
|
+
if (first === false) {
|
146
|
+
append(COMMA);
|
147
|
+
} else {
|
148
|
+
first = false;
|
149
|
+
}
|
150
|
+
|
151
|
+
append(encodeString(k));
|
152
|
+
append(":");
|
153
|
+
serialize(v);
|
154
|
+
}
|
155
|
+
}
|
156
|
+
append("}");
|
157
|
+
break;
|
158
|
+
default:
|
159
|
+
append(NULL);
|
160
|
+
}
|
161
|
+
}
|
162
|
+
}
|
163
|
+
|
164
|
+
serialize(o);
|
165
|
+
|
166
|
+
return buffer.toString();
|
167
|
+
}
|
168
|
+
|
169
|
+
module.exports = stringify;
|
package/package.json
CHANGED
@@ -32,10 +32,9 @@
|
|
32
32
|
"jsonminify": "^0.2.3",
|
33
33
|
"marko-async": "^2.0.0",
|
34
34
|
"marko-layout": "^2.0.0",
|
35
|
-
"minimatch": "^0.
|
35
|
+
"minimatch": "^9.0.0",
|
36
36
|
"property-handlers": "^1.0.0",
|
37
37
|
"raptor-args": "^1.0.0",
|
38
|
-
"raptor-json": "^1.0.1",
|
39
38
|
"raptor-logging": "^1.0.1",
|
40
39
|
"raptor-modules": "^1.0.5",
|
41
40
|
"raptor-polyfill": "^1.0.0",
|
@@ -69,5 +68,5 @@
|
|
69
68
|
"logo": {
|
70
69
|
"url": "https://raw.githubusercontent.com/marko-js/branding/master/marko-logo-small.png"
|
71
70
|
},
|
72
|
-
"version": "2.11.
|
71
|
+
"version": "2.11.3"
|
73
72
|
}
|
package/taglibs/core/ForNode.js
CHANGED
@@ -16,7 +16,7 @@
|
|
16
16
|
'use strict';
|
17
17
|
var extend = require('raptor-util').extend;
|
18
18
|
var forEachEntry = require('raptor-util').forEachEntry;
|
19
|
-
var stringify = require('
|
19
|
+
var stringify = require('../../compiler/util/stringify');
|
20
20
|
var isObjectEmpty = require('raptor-util/isObjectEmpty');
|
21
21
|
var requireVarName = require('./requireVarName');
|
22
22
|
|
package/.npmignore
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
/test
|