xml-conditional-compile
v1.0.2
Published
xml conditional compile lib
Downloads
4
Maintainers
Readme
babel-plugin-conditional-compile
Overview
A pure function lib as core for HTML conditional compilation.
Install
To install the plugin, run the following command:
npm install --save-dev xml-conditional-compile
Or, if you're using Yarn:
yarn add --dev xml-conditional-compile
Usage
Configuration
This library serves as the core library and provides APIs in pure functional form. It can be used in extensions or plugins of various building tools to help complete conditional compilation.
import xmlConditionalCompile from 'xml-conditional-compile'
const newHtmlStr = xmlConditionalCompile(originalHtmlStr)
Coding with Conditional Compilation
In your xml files, you can use special comments to mark code blocks for conditional compilation.
<body>
<!-- ifdef targetPlat=WX|TT -->
<h1>如果targetPlat命中WX|TT这里就会保留</h1>
<h1>gnidaeH1</h1>
<!-- endif -->
<p>My first paragraph.</p>
<!-- ifndef targetPlat=WX|TT -->
<h1>如果targetPlat命中WX|TT这里就会删除</h1>
<h1>gnidaeH2</h1>
<!-- endif -->
</body>