Socket
Socket
Sign inDemoInstall

@uking/marmot

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@uking/marmot

A lightweight and fast javascript native template rendering engine that supports browsers, FibJS and NodeJS.


Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

@uking/marmot

A lightweight and fast javascript native template rendering engine that supports browsers, FibJS and NodeJS.

Note

  1. Component name must start with a capital letter
  2. Component name can not be Template or Slot

usage

const {html,Component,render} = require('@uking/marmot')

class Layout extends Component {
  render({title}){
    return html`
      <!DOCTYPE html>
      <html lang="en">
        <head>
           <meta charset="UTF-8">
           <title>${title}</title>
           <Slot name="header" />
        </head>
        <body>
        	<Slot />
        </body>
      </html>
    `
  }
}

class Page extends Component {
  // Register required components
  components(){
    return {
      Layout
    }
  }
  render({title,data}){
    return html`
    	<Layout title="this is title">
    		<Template slot="header">
    			<style>
    			body{
    				font-size:16px;
    			}
    			</style>
    		</Template>
    		<h2>${title}</h2>
    		<div>this is body content</div>
            <ul>
                ${data.map(item =>`<li>${item}</li>`)}
            </ul>
    	</Layout>
    `
  }
}
const data = ['test1','test2','test3']
const str = render(html`<Page title="Test" data="${data}" />`,{Page})
console.log(str)

Keywords

FAQs

Package last updated on 10 May 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc