Skip to content

Commit

Permalink
fix: escape linebreak to \n
Browse files Browse the repository at this point in the history
  • Loading branch information
IOriens committed Aug 21, 2017
1 parent 2ecc7da commit 19aa0e5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 25 deletions.
3 changes: 2 additions & 1 deletion src/compiler/parser/text-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ const escapeTxt = function (str) {
{ ori: /"/g, n: '\\x22' },
{ ori: /'/g, n: '\\x27' },
{ ori: /&/g, n: '\\x26' },
{ ori: /=/g, n: '\\x3d' }
{ ori: /=/g, n: '\\x3d' },
{ ori: /\n/g, n: '\\n' }
]
map.forEach(v => (str = str.replace(v.ori, v.n)))
return str
Expand Down
34 changes: 10 additions & 24 deletions test/pages/index/index.wxml
Original file line number Diff line number Diff line change
@@ -1,33 +1,19 @@
<import src="../../../common/head.wxml" />
<import src="../../../common/foot.wxml" />
<import src="../../../common/head.wxml"/>
<import src="../../../common/foot.wxml"/>

<view class="container">
<template is="head" data="{{title: 'view'}}"/>
<template is="head" data="{{title: 'request'}}"/>

<view class="page-body">
<view class="page-section">
<view class="page-section-title">
<text>flex-direction: row\n横向布局</text>
</view>
<view class="page-section-spacing">
<view class="flex-wrp" style="flex-direction:row;">
<view class="flex-item demo-text-1"></view>
<view class="flex-item demo-text-2"></view>
<view class="flex-item demo-text-3"></view>
</view>
</view>
<view class="page-body-wording">
<text class="page-body-text">
点击向服务器发起请求 jjkjkj
</text>
</view>
<view class="page-section">
<view class="page-section-title">
<text>flex'-direction: \\"\tcolu`~?,/.,.;':"{}[]-+=m!@#$%^&*()_n\\n纵{{"jkjkjk\\n\'jkj"}}向布局</text>
</view>
<view class="flex-wrp" style="flex-direction:column;">
<view class="flex-item flex-item-V demo-text-1"></view>
<view class="flex-item flex-item-V demo-text-2"></view>
<view class="flex-item flex-item-V demo-text-3"></view>
</view>
<view class="btn-area">
<button bindtap="makeRequest" type="primary" disabled="{{buttonDisabled}}" loading="{{loading}}">request</button>
</view>
</view>

<template is="foot" />
<template is="foot"/>
</view>

0 comments on commit 19aa0e5

Please sign in to comment.