fix assign tag regex to include linebreaks in value

This commit is contained in:
Andrew Barclay
2018-11-22 09:31:22 +08:00
committed by Jun Yang
parent d65ea14b9f
commit 2055258193
9 changed files with 1118 additions and 1134 deletions
+1 -1
View File
@@ -2225,7 +2225,7 @@ function For (liquid, Liquid) {
}
function Assign (liquid, Liquid) {
var re = new RegExp('(' + identifier.source + ')\\s*=(.*)');
var re = new RegExp('(' + identifier.source + ')\\s*=([^]*)');
var AssignScope = Liquid.Types.AssignScope;
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -2171,7 +2171,7 @@
}
function Assign (liquid, Liquid) {
var re = new RegExp('(' + identifier.source + ')\\s*=(.*)');
var re = new RegExp('(' + identifier.source + ')\\s*=([^]*)');
var AssignScope = Liquid.Types.AssignScope;
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+1103 -1127
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -3,7 +3,7 @@ import {identifier} from '../lexical.js'
import {create} from '../util/underscore.js'
export default function (liquid, Liquid) {
const re = new RegExp(`(${identifier.source})\\s*=(.*)`)
const re = new RegExp(`(${identifier.source})\\s*=([^]*)`)
const {AssignScope} = Liquid.Types
liquid.registerTag('assign', {
+8
View File
@@ -41,6 +41,14 @@ describe('tags/assign', function () {
return expect(liquid.parseAndRender(src))
.to.eventually.equal('A')
})
it('should assign as filter across multiple lines as result', function () {
const src = `{% assign foo="a b"
| capitalize
| split: " "
| first %}{{foo}}`
return expect(liquid.parseAndRender(src))
.to.eventually.equal('A')
})
it('should assign var-1', function () {
const src = '{% assign var-1 = 5 %}{{ var-1 }}'
return expect(liquid.parseAndRender(src)).to.eventually.equal('5')