Skip to content

tcs211/tohtml

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

wrihtml

Example

  1. 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>
    
  2. 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>
    
  3. with child element

    var html = wrihtml(
     `div/ [col-12 col-md-6]
     h1  title 1
     h2  title 2
     /div`
     )
    

    Output

    title 1

    title 2

    <div class="col-12 col-md-6">
        <h1>title 1</h1>
        <h2>title 2</h2>
    </div>
    
  4. with multiple line inner text

     var html = wrihtml(
     `h1/ [text-dark]
     // first line text in h1,
     // 2nd line text in h1
     /h1`)
    

    Output

    first line text in h1, 2nd line text in h1

  5. Ignore line started with '<'

     var html = wrihtml(
     `h1 [text-dark] h1 text
     <h2>h2 text</h2>
     h3 h3 text
     `)
    

    Output

    h1 text

    h2 text

    h3 text

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published