npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@mini2/jst

v1.0.0

Published

JavaScript template engine for Node.js with optional React rendering

Downloads

115

Readme

JST

JST, içinde JavaScript çalıştırılabilen bir Node.js template engine'dir. Kendisi sunucu başlatmaz.

Kurulum

Yayımlanmış paketi kurmak için:

npm install @mini2/jst

Bu depodan yerel tarball üretmek için npm install, ardından npm pack çalıştırın. Oluşan dosya mini2-jst-1.0.0.tgz biçimindedir ve npm install ./mini2-jst-1.0.0.tgz ile kurulabilir. Node.js 18 veya üstü gerekir.

Sözdizimi

<?jst const title = "Merhaba"; ?>
<h1><?jst= title ?></h1>
<?jst for (const item of items) { ?>
  <p><?jst= item ?></p>
<?jst } ?>
<?jst- trustedHtml ?>

| Biçim | Anlamı | | --- | --- | | <?jst ... ?> | JavaScript çalıştırır. await kullanılabilir. | | <?jst= ifade ?> | İfadeyi HTML karakterlerini kaçırarak yazdırır. | | <?jst- ifade ?> | İfadeyi ham HTML olarak yazdırır. | | print(değer) | Eski şablonlarla uyumlu ham çıktı üretir. | | printEscaped(değer) | HTML karakterlerini kaçırarak çıktı üretir. |

Şablon içindeki JavaScript, Node.js'in vm modülünde çalışır. vm güvenlik sınırı değildir; yalnızca güvendiğiniz şablonları çalıştırın. JSX sözdizimi .jst dosyası içinde derlenmez; React öğelerini uygulama kodunda oluşturup şablona geçirin.

Kullanım

const { render, renderFile, compile } = require("@mini2/jst");

const html = await render("<h1><?jst= title ?></h1>", { title: "A&B" });
// <h1>A&amp;B</h1>

const page = compile("<p><?jst= name ?></p>");
await page({ name: "Ada" });
await page({ name: "Deniz" });

await renderFile("./views/home.jst", { title: "Ana sayfa" });

render ve renderFile her zaman Promise<string> döndürür. Şablon değişkenleri ikinci argümandaki nesneden gelir. Eski HTTP değişkenleri uygulama tarafından açıkça verilebilir: renderFile("view.jst", { GET: req.query, POST: req.body, HEADERS: req.headers }).

Veritabanı bağlantısı da uygulamanın sorumluluğundadır. Örneğin mevcut src/www/mysql.jst örneğini renderFile("src/www/mysql.jst", { mysql: dbClient }) ile kullanabilirsiniz.

Parçalar ve modüller

include yolu, onu çağıran .jst dosyasına göre çözülür ve HTML döndürür:

<?jst print(await include("./card.jst", { name: "Ada" })); ?>

Eski await require("./card.jst", { name: "Ada" }) kullanımı da parçayı doğrudan çıktıya ekler. Diğer require(...) çağrıları, dosyanın konumuna göre normal Node.js modüllerini yükler. Döngüsel parça çağrıları hata verir.

Express ile

Express uygulaması paketi isteğe bağlı olarak kendi sunucusuna bağlayabilir:

const express = require("express");
const { __express } = require("@mini2/jst");
const app = express();

app.engine("jst", __express);
app.set("views", "./views");
app.set("view engine", "jst");
app.get("/", (req, res) => res.render("home", { title: "Ana sayfa" }));
app.listen(3000);

React ile

React desteği için ayrıca react ve react-dom kurun:

npm install react react-dom
const React = require("react");
const { renderFile } = require("@mini2/jst");
const card = React.createElement("strong", null, "Merhaba");
const html = await renderFile("./views/page.jst", { card });

page.jst:

<main><?jst- renderReact(card) ?></main>

renderReact(element) statik HTML üretir. Etkileşimli bir React ağacı için renderReact(element, { hydrate: true }) kullanın ve istemci kodunda aynı ağacı hydrateRoot ile bağlayın. React sunucu render işleminin sınırlamaları için React belgelerine bakın.

Geliştirme

npm test
npm pack --dry-run

Paket yalnızca derlenmiş dist dosyalarını yayımlar. TypeScript tür tanımları paketle birlikte gelir.

Yayınlama

@mini2 kapsamına yayınlama yetkisi olan npm hesabıyla giriş yaptıktan sonra:

npm whoami
npm run release:check
npm run release

release:check, yayınlanacak dosyaları ve yaşam döngüsü betiklerini gerçek yayın yapmadan kontrol eder. release, paketi npm kayıt defterine herkese açık olarak yayımlar. Her gerçek yayından önce prepublishOnly testleri çalıştırır; prepack derlenmiş dosyaları hazırlar. Aynı sürüm tekrar yayımlanamayacağı için sonraki sürümden önce npm version patch veya uygun başka bir sürüm artışı yapın.