Wondering what’s next for npm?Check out our public roadmap! »

    @snooty/html

    1.5.1 • Public • Published

    func-html

    It's simple html/xml functional tempate system. Simple example:

    const h = require('func-html');
    
    const template = h('html', 
      h('body', 
        h('h1', 'Hello world!')
      )
    );
    
    console.log(template());
    // Will out: <html><body><h1>Hello World!</h1></body></html>
    
    

    More complex... As you can see h function returns function... so, we can do like this:

    const h = require('func-html');
    const context = { message: 'Hello world!' };
    const template = h('html', 
      h('body', 
        h('h1', (context) => context.message)
      )
    );
    
    console.log(template(context));
    // Will out: <html><body><h1>Hello World</h1></body></html>
    
    

    And, with attributes

    const h = require('func-html');
    const context = { message: 'Hello world!' };
    const getter = (context) => context.message;
    const template = h('html', 
      h('body', 
        h('h1', getter, { title: getter })
      )
    );
    
    console.log(template(context));
    // Will out: <html><body><h1 title="Hello world!">Hello World</h1></body></html>
    
    

    Install

    npm i @snooty/html

    DownloadsWeekly Downloads

    1

    Version

    1.5.1

    License

    ISC

    Unpacked Size

    16.6 kB

    Total Files

    7

    Last publish

    Collaborators

    • avatar
    • avatar