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

sectplating

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sectplating

An easy to use, fast and lightweight template engine.

latest
Source
npmnpm
Version
1.0.4
Version published
Maintainers
1
Created
Source

SectPlating

An easy to use, fast and lightweight template engine.

npm i sectplating

Example:

const { sectplating } = require("sectplating");

const rendered = sectplating("Hello {globe}, This Is The Power Of: {cool_name}!", { globe: "World", cool_name: "SectPlating" });

console.log(rendered); // Output: Hello World, This Is The Power Of: SectPlating!

With File Example:

const { renderFile, render } = require("sectplating");

const path = "./index.html" // File Content: <h1>{example}</h1>
const options = { example: "Hello, World!" }

// Built-In:
renderFile(path, options, (err, output) => {
  if (err) return console.log(err);
  
  console.log(output); // Output: <h1>Hello, World!</h1>
})

// Custom:
let filecontent = "ERROR: File Reading Error!"

try {
   filecontent = fs.readFileSync(path, 'utf8');
 } catch (err) {
   logcon.error(`ERROR: File Reading Error: ${err}`);
   filecontent = "ERROR: File Reading Error: " + err;
}

console.log(render(filecontent, options)); // Output: <h1>Hello, World!</h1>

Supports Express.js

const express = require("express")
const app = express()

const options = { example: "Hello, World!" }

app.engine("html", require("sectplating").__express) // Or: app.engine('html', require("sectplating").renderFile)

app.get('/', function (req, res) {
  res.render("index.html", options)
})

Options:

{ ignoreMissing = false, transform = ({ value }) => value }

Keywords

template

FAQs

Package last updated on 23 Nov 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