Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tarkine

Package Overview
Dependencies
Maintainers
0
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tarkine

tarkine - A powerful and flexible template engine for Node.js applications.

  • 0.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4
decreased by-20%
Maintainers
0
Weekly downloads
 
Created
Source

Tarkine is a powerful and flexible template engine for Node.js applications. It provides a simple syntax for creating dynamic HTML templates with various features like comments, escaping, conditionals, loops, includes, blocks, and code execution.

npm version Downloads License

Installation

npm install tarkine

Usage

const tarkine = require('tarkine');

const output = tarkine.renderFile("./template.html", {
    username: "John Doe",
    html: "<span>Some HTML</span>",
    status: true,
    array: [1, 2, 3],
    object: {
        username: "johndoe",
        age: 30
    },
});

console.log(output);

Usage in expressjs:

const tarkine = require("tarkine") // import
const express = require("express")
const app = express()


app.set("view engine", "html")
app.engine("html", tarkine.renderFile)

app.get("/", (req, res) => {
    res.render("index", {
        username: "tarkine"
    })
})

app.listen(3000)

Syntax

  • Comments
{{# This is a comment }}
  • Escaping
{{ variable }} // Escaped output
{{- variable }} // Unescaped output
{{= variable }} // Fully escaped output (including includes)
  • Conditionals
{{ if(condition) }}
  // content
{{ else if(otherCondition) }}
  // content
{{ else }}
  // content
{{/}}
  • Loops
{{ for(value, index in array) }}
  // content
{{/}}

{{ for(value, key in object) }}
  // content
{{/}}
  • Includes
{{ include("./partial", { data: "value" }) }}
  • Blocks
{{define blockName(param1, param2) }}
  // block content
{{/}}

{{ blockName(arg1, arg2) }}
  • Code Execution
{{~
  // JavaScript code here
}}
  • Attributes
<div>
    <button disabled="isLoggedIn">Login</button>
    <button disabled="isLoggedIn === true">Login</button>
</div>

Keywords

FAQs

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