1.0.10 • Published 2 years ago
wrihtml v1.0.10
wrihtml
Example
Element with class
var wrihtml = require('wrihtml'); var html = wrihtml( `div [text-center bg-danger] This is a div` )
Output: This is a div
<div class="text-center bg-danger">This is a div</div>
Element with attributes
var html = wrihtml( `button [class="btn btn-danger" onclick="alert('alert!')"] a button` )
Output: a button
<button class="btn btn-danger" onclick="alert('alert!')">a button</button>
with child element
var html = wrihtml( `div/ [col-12 col-md-6] h1 title 1 h2 title 2 /div` )
Output
<div class="col-12 col-md-6"> <h1>title 1</h1> <h2>title 2</h2> </div>
with multiple line inner text
var html = wrihtml( `h1/ [text-dark] // first line text in h1, // 2nd line text in h1 /h1`)
Output
Ignore line started with '<'
var html = wrihtml( `h1 [text-dark] h1 text <h2>h2 text</h2> h3 h3 text `)
Output