Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A javascript template engine, simple, easy & extras, support webpack, rspack, vite, rollup, esbuild, parcel, browserify, fis and gulp.

License

NotificationsYou must be signed in to change notification settings

yanhaijing/template.js

Repository files navigation

licenseCI

English |简体中文

A javascript template engine that is simple, easy to use, and supports webpack, rspack, vite, esbuild, rollup, parcel, browserify, fis, and gulp.

Features

  • Native JS syntax, template parsing, compilation, and rendering
  • Supports all browsers and Node, supports TypeScript
  • Precompilation supports mainstream packaging tools
  • Custom configurations, decorators, and functions
  • Data filtering support
  • Exception capture functionality
  • Subtemplates
  • Sandbox mode
  • Supports JIT and AOT compilation modes
  • Provides CLI integrated tools
  • Provides support for editor plugins

User Guide

template.js is a better way than concatenating strings, Click to usecodesandbox for a quick demo

Template example

<ul>    <%for(var i = 0; i < list.length; i++) {%>        <li><%:=list[i].name%></li>    <%}%></ul>

Data example

constdata={list:[{name:'yan'},{name:'haijing'}],};

Render output

<ul><li>yan</li><li>haijing</li></ul>

Editor plugins supported by template.js

EditorPlugin
Vscodehighlight plugin
Sublimehighlight plugin
Atomhighlight plugin
WebStormTODO

Quickly initialize a project using CLI tools

$ npx @templatejs/cli new myapp# Choose the corresponding platform# ❯ webpack#   rspack#   vite#   rollup#   esbuild#   parcel2#   parcel1#   fis3#   browserify#   gulp#   browser

If you already have a project, you can choose a corresponding plugin, template.js supports different usage methods

PlatformPlugin
webpack / rspacktemplate-loader
vite / rolluprollup-plugin-templatejs
esbuildesbuild-plugin-templatejs
parcel2parcel-transformer-template
parcel1parcel-plugin-template
fisfis-parser-template
browserifybrowserify-templatejs
gulpgulp-templatejs
Native web & Node.jstemplate_js
Unsupported platformsYou can write a plugin yourself, please see@templatejs/precompiler

Other packages summary

Developer Guide

This project uses lerna to manage multiple plugins. Common lerna commands are as follows, note that the npx prefix cannot be left out:

$ npx lerna init# Initialize$ npx lerna create @templatejs/parser# Create a package$ npx lerna add yargs --scope=@templatejs/parser# Install package dependencies$ npx lerna list# List all packages$ npx lerna bootstrap# Install all dependencies$ npx lerna link# Create all soft links$ npx lerna changed# List the packages to be updated next time when using lerna publish$ npx lerna publish# Will tag, upload git, upload npm

Release steps, modify changelog

$ yarn lint$ yarn build$ yarntest$ npx lerna publish

Release without tagging, suitable for test package.

$ yarn lint$ yarn build$ yarntest$ lerna version --no-git-tag-version$ npx lerna publish from-package --dist-tag next

Contributors List

contributors

Changelog

CHANGELOG.md

Planned Feature List

TODO.md

Who is Using

To learn about who is using this,click here.

Related Links

About

A javascript template engine, simple, easy & extras, support webpack, rspack, vite, rollup, esbuild, parcel, browserify, fis and gulp.

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

    Packages

    No packages published

    Contributors7


    [8]ページ先頭

    ©2009-2025 Movatter.jp