New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

hvist

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hvist

Render Language for XML/HTML

latest
npmnpm
Version
2.3.0
Version published
Weekly downloads
3
50%
Maintainers
1
Weekly downloads
 
Created
Source

Sample


import hvist from 'hvist'

// compile template from file
const filename = '/path/to/file.at';
const fileTempalate = await hvist.compileFile(filename);

// compile template from source
const source = '?title; html { head title $title; body "Some content" }';
const template = await hvist.compile(source);

// any render arguments
const args = {title: 'Some title'};

// render template to text
const text = await template.text(args);

console.log(text);

// render template to buffer
const buffer = await template.buffer(args);

// render template to file
await template.save('/path/to/result.html', args);

// render template to output stream
await template.print(args);

// render template to any stream
const stream = {
	write(chunk){ console.log(chunk) }
};

await template.pipe(stream, args);

Template language sample

main.at

// optional argument title
?title = 'Default Title'

@doctype(html)

html(lang='en') {

	head {
		title $title.toUpperCase();
	}

	// @ - insert include contents here
	body main @
}

page.at


// replace Article tag
@module Article {
	?image; // require argument
	section.article {
		img(src=$image); // print img tag
		@; // insert content
	}
}

// replace Title tag
@module Title { h2.article @ }

// replace Content tag
@module Content { p.content @ }

// import main file and insert @-content
@import 'main.at'(title='Page Title') {

	Article(image='./image.png') {
		Title 'Article Title';
		Content 'Article Content';
	}
}

Output HTML (without white spaces)

<!DOCTYPE html>
<html lang="en">

  <head>
    <title>PAGE TITLE</title>
  </head>

  <body>
    <main>
      <section class="article">
      	<img src="./image.png" />
        <h2 class="article">Article Title</h2>
        <p class="article">Article Content</p>
      </section>
    </main>
  </body>

</html>

Keywords

template

FAQs

Package last updated on 24 Oct 2023

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