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

weex-templater

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

weex-templater - npm Package Compare versions

Comparing version 0.3.2 to 0.3.3

lib/richtext.js

5

index.js
var parse5 = require('parse5')
var validator = require('./lib/validator')
var richtext = require('./lib/richtext')

@@ -49,3 +50,3 @@ /**

if (attr.name === 'if') {
validator.checkElse(attr.value, output)
validator.checkIf(attr.value, output, true)
}

@@ -147,2 +148,4 @@ })

richtext.walkAndFormat(output.result)
done(null, {

@@ -149,0 +152,0 @@ jsonTemplate: output.result,

2

lib/exp.js

@@ -12,3 +12,3 @@ var expParser = require('./parsers/expression')

var ret
expContent = expContent.trim()
expContent = expContent.trim().replace(/\"/g, '\'')
if (!textParser.isExpr(expContent)) {

@@ -15,0 +15,0 @@ ret = expContent

@@ -45,2 +45,7 @@ var exp = require('./exp')

},
richtext: {
defaultAttr: {
append: 'once'
}
},
lastVisited: {

@@ -313,10 +318,2 @@ events: COMMON_EVENTS

*/
function checkElse(value, output) {
checkIf(value, output, true)
}
/**
* @param {string} value
* @param {object} output{result, deps[], log[]}
*/
function checkRepeat(value, output) {

@@ -433,3 +430,2 @@ if (value) {

checkIf: checkIf,
checkElse: checkElse,
checkRepeat: checkRepeat,

@@ -436,0 +432,0 @@ checkAppend: checkAppend,

{
"name": "weex-templater",
"version": "0.3.2",
"version": "0.3.3",
"description": "Weex <template> transformer",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -138,9 +138,2 @@ # Weex `<template>` Transformer

}
styler.validate(json, function (err, data) {
err
data.jsonTemplate
data.deps[]
data.log[]
})
```

@@ -445,3 +445,3 @@ var chai = require('chai')

{type: 'text', attr: {value: function () {return this.data.items[0].title[0].valueDesc}}},
{type: 'text', attr: {value: function () {return (this.a) + ' and ' + (this.b[this.c.d][0]?'a':"b") + ' hhh ' + (parseInt("65"))}}}
{type: 'text', attr: {value: function () {return (this.a) + ' and ' + (this.b[this.c.d][0]?'a':'b') + ' hhh ' + (parseInt('65'))}}}
]

@@ -534,2 +534,38 @@ },

})
it('parse richtext', function (done) {
var code = '<container> <richtext> <text style="padding: 8; color: {{active ? \'#ff0000\' : \'#00ff00\'}};"> {{xxx}} </text> </richtext> <richtext> <text if="a" repeat="list" class="a {{b}}"> {{xxx}} </text> <image class="a {{b}}" style="padding: 8; color: {{active ? \'#ff0000\' : \'#00ff00\'}};"></image> </richtext> <container> <text if="a" repeat="list">{{xxx}}</text> <image id="{{x}}" class="a {{x}} c" src="{{y}}" style="opacity: {{z}}"></image> </container> </container>'
var expected = {
jsonTemplate: {
type: 'container',
children: [{
type: 'richtext',
append: 'once',
attr: {
value: function () {return [{type: 'text', style: {padding: 8, color: this.active?'#ff0000':'#00ff00'}, attr: {value: this.xxx}}]}
}
},
{
type: 'richtext',
append: 'once',
attr: {
value: function () {return [{type: 'text', shown: this.a, repeat: this.list, style: (function () { var _s = this.classStyle; return Object.assign({}, _s['a'], _s[this.b]); }).call(this), attr: {value: this.xxx}}, {type: 'image', style: (function () { var _s = this.classStyle; return Object.assign({padding: 8, color: this.active?'#ff0000':'#00ff00'}, _s['a'], _s[this.b]); }).call(this)}]}
}
},
{
type: 'container',
children: [
{type: 'text', shown: function () {return this.a}, repeat: function () {return this.list}, attr: {value: function () {return this.xxx}}},
{type: 'image', id: function () {return this.x}, classList: function () {return ['a', this.x, 'c']}, attr: {src: function () {return this.y}}, style: {opacity: function () {return this.z}}}
]
}]
},
deps: ['container', 'richtext', 'text', 'image'],
log: []
}
templater.parse(code, function (err, result) {
expect(stringify(result)).eql(stringify(expected))
done()
})
})
})
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