🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

ulka-parser

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ulka-parser

Templating engine for ulka static site generator

0.4.1
latest
Source
npm
Version published
Weekly downloads
2.2K
72.75%
Maintainers
1
Weekly downloads
 
Created
Source

logo

NPM  MIT  CI

Ulka Praser is a templating engine made for ulkajs.

🚀 Usage

ClI

npx ulka-parser --t /path/to/template/folder/or/file --o /path/to/output/folder

# OR

npm install -g ulka-parser
ulka-parser --t /path/to/template/folder/or/file --o /path/to/output/folder

Javascript Api

npm i ulka-parser
const { render } = require("ulka-parser")

const template = `Hello, I am {% name %}`

const data = render(template, { name: "Roshan Acharya" })
console.log(data)
// Hello, I am Roshan Acharya

Template Guide

You can write nodejs code inside {% %} in ulka template.

index.ulka

{% const name = "Roshan Acharya".toUpperCase() %}

<h1>Hello, I am {% name %}</h1>

index.html

<h1>ROSHAN ACHARYA</h1>

Variables

index.ulka

{% const name = "I Love Javascript" %}

{% name %}

index.html

I Love Javascript

Loops

index.ulka

{% const languages = [ { name: "javascript", short: "js" }, { name: "typescript", short: "ts" }, ]; %}

<div>
  {% languages.map(lang => `<h1>I Love ${lang.name} (${lang.short}).</h1>`) %}
</div>

index.html

<div>
  <h1>I Love javascript (js).</h1>
  <h1>I Love typescript (ts).</h1>
</div>

Conditionals

index.ulka

{% const iAmWinner = true %}

{% iAmWinner ? "I am Winner": "I am loser" %}

index.html

I am Winner

Import NPM modules

{%  const dayjs = require('dayjs') %}

{% dayjs().format() %}

Ulka parser with express

const express = require("express")
const { engine } = require("ulka-parser")

const app = express()

app.engine("ulka", engine())
app.set("views", "./views")
app.set("view engine", "ulka")

app.get("/", (req, res) => {
  res.render("index", { name: "Roshan Acharya" })
})

app.listen(3000, () => {
  console.log("Server listening on port 3000")
})

FAQs

Package last updated on 14 Oct 2020

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