mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-15 04:10:40 -07:00
fix: newline_to_br filter should output <br /> instead of <br/>, fixes #320
This commit is contained in:
@@ -28,7 +28,7 @@ export function escapeOnce (str: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function newlineToBr (v: string) {
|
export function newlineToBr (v: string) {
|
||||||
return v.replace(/\n/g, '<br/>')
|
return v.replace(/\n/g, '<br />\n')
|
||||||
}
|
}
|
||||||
|
|
||||||
export function stripHtml (v: string) {
|
export function stripHtml (v: string) {
|
||||||
|
|||||||
+8
-1
@@ -1,4 +1,4 @@
|
|||||||
import { Liquid } from '../..'
|
import { Liquid } from '../../src/liquid'
|
||||||
import { Liquid as LiquidUMD } from '../../dist/liquid.browser.umd.js'
|
import { Liquid as LiquidUMD } from '../../dist/liquid.browser.umd.js'
|
||||||
import { expect, use } from 'chai'
|
import { expect, use } from 'chai'
|
||||||
import * as chaiAsPromised from 'chai-as-promised'
|
import * as chaiAsPromised from 'chai-as-promised'
|
||||||
@@ -95,4 +95,11 @@ describe('Issues', function () {
|
|||||||
)
|
)
|
||||||
expect(html).to.equal('falsefalse')
|
expect(html).to.equal('falsefalse')
|
||||||
})
|
})
|
||||||
|
it('#321 comparison for empty/nil', async () => {
|
||||||
|
const engine = new Liquid()
|
||||||
|
const html = await engine.parseAndRender(
|
||||||
|
`{{ 'a \n b \n c' | newline_to_br | split: '<br />' }}`
|
||||||
|
)
|
||||||
|
expect(html).to.equal('a ,\n b ,\n c')
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -26,9 +26,9 @@ describe('filters/html', function () {
|
|||||||
'there\n' +
|
'there\n' +
|
||||||
'{% endcapture %}' +
|
'{% endcapture %}' +
|
||||||
'{{ string_with_newlines | newline_to_br }}'
|
'{{ string_with_newlines | newline_to_br }}'
|
||||||
const dst = '<br/>' +
|
const dst = '<br />\n' +
|
||||||
'Hello<br/>' +
|
'Hello<br />\n' +
|
||||||
'there<br/>'
|
'there<br />\n'
|
||||||
return test(src, dst)
|
return test(src, dst)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user