All Projects → joe-sky → nornj

joe-sky / nornj

Licence: MIT license
More exciting JS/JSX based on Template Engine, support control flow tags, custom directives, two-way binding, filters and custom operators.

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to nornj

Sowing Machine
🌱A React UI toolchain & JSX alternative
Stars: ✭ 64 (-34.02%)
Mutual labels:  jsx, babel-plugin
Babel Plugin Jsx Two Way Binding
🍺 A two-way data binding solution for React
Stars: ✭ 15 (-84.54%)
Mutual labels:  jsx, babel-plugin
babel-plugin-hyperscript-to-jsx
This plugin transforms react-hyperscript into JSX. Intended to be used as codemod.
Stars: ✭ 20 (-79.38%)
Mutual labels:  jsx, babel-plugin
Babel Plugin React Html Attrs
Babel plugin which transforms HTML and SVG attributes on JSX host elements into React-compatible attributes
Stars: ✭ 170 (+75.26%)
Mutual labels:  jsx, babel-plugin
Babel Plugin Jsx Adopt
Stars: ✭ 94 (-3.09%)
Mutual labels:  jsx, babel-plugin
Jsx Control Statements
Neater If and For for React JSX
Stars: ✭ 1,305 (+1245.36%)
Mutual labels:  jsx, babel-plugin
Htm
Hyperscript Tagged Markup: JSX alternative using standard tagged templates, with compiler support.
Stars: ✭ 7,299 (+7424.74%)
Mutual labels:  jsx, babel-plugin
Babel Plugin React Persist
Automatically useCallback() & useMemo(); memoize inline functions
Stars: ✭ 91 (-6.19%)
Mutual labels:  jsx, babel-plugin
Babel Plugin Transform Incremental Dom
Turn JSX into IncrementalDOM
Stars: ✭ 146 (+50.52%)
Mutual labels:  jsx, babel-plugin
typesafe-templates
Template engine that leverages JSX to generate JavaScript code from TypeScript code files rather than text templates.
Stars: ✭ 27 (-72.16%)
Mutual labels:  template-engine, jsx
React-Netflix-Clone
A Fully Responsive clone of Netflix website built using React.JS as a Front-end & Firebase as a Back-end.
Stars: ✭ 91 (-6.19%)
Mutual labels:  jsx
vue3-jd-h5
🔥 Based on vue3.0.0, vant3.0.0, vue-router v4.0.0-0, vuex^4.0.0-0, vue-cli3, mockjs, imitating Jingdong Taobao, mobile H5 e-commerce platform! 基于vue3.0.0 ,vant3.0.0,vue-router v4.0.0-0, vuex^4.0.0-0,vue-cli3,mockjs,仿京东淘宝的,移动端H5电商平台!
Stars: ✭ 660 (+580.41%)
Mutual labels:  jsx
ultron-ele
The world’s fastest LMS engine based on Gatsby -- Deliver knowledge with fun!
Stars: ✭ 27 (-72.16%)
Mutual labels:  template-engine
vpl
Vuejs-syntax like template-engine for Go
Stars: ✭ 19 (-80.41%)
Mutual labels:  template-engine
escapevelocity
A subset reimplementation of Apache Velocity with a much simpler API.
Stars: ✭ 28 (-71.13%)
Mutual labels:  template-engine
Velocity
🚀Velocity template engine for JavaScript and PHP.
Stars: ✭ 33 (-65.98%)
Mutual labels:  template-engine
jinja.dart
Jinja2 template engine port for Dart.
Stars: ✭ 38 (-60.82%)
Mutual labels:  template-engine
react-ui-components
React UI Components (npm @assenti/rui-components)
Stars: ✭ 21 (-78.35%)
Mutual labels:  jsx
jquery-smarty
jQuery Smarty Plugin (jQSmarty) is a port of the Smarty Templating Engine to Javascript/jQuery, offering a familiar client-side templating solution
Stars: ✭ 18 (-81.44%)
Mutual labels:  template-engine
fjb
fast javascript bundler 📦
Stars: ✭ 103 (+6.19%)
Mutual labels:  jsx

NornJ

NPM Version License Travis CI Status Codecov NPM Downloads Minzipped Size

English | 简体中文

Introduction

NornJ(pronounced [ˌnɔ:nˈdʒeɪ],abbreviated as nj) is a JS/JSX extension solution based on Template Engine.

Documents

Packages

Package Badges
nornj NPM Version NPM Downloads Minzipped Size
nornj-react NPM Version NPM Downloads Minzipped Size
nornj-loader NPM Version NPM Downloads
babel-plugin-nornj-in-jsx NPM Version NPM Downloads
babel-preset-nornj-with-antd NPM Version NPM Downloads

Overview

In React development, the JSX can use almost all the syntax of javascript and it's very flexible. But if we use NornJ with React and JSX, we can do better, because it can gives JSX new features:

  • Support control statements:
<each of={[1, 2, 3]}>
  <i>{item}</i>
</each>
  • Support directives:
<img n-show={false} />
  • Support filters:
<button>{n`foo | upperFirst`}</button>
  • Support custom operators:
<input value={n`(1 .. 100).join('-')`} />

NornJ presets the above JSX enhancement syntaxs, and also supports custom extensions of more syntaxs. It provides two kinds of similar API: JSX and Tagged templates, can adapt to the preferences of different users 😉.

Basic

class App extends Component {
  addTodo = e => {
    const { todos = [] } = this.state;
    this.setState({ todos: todos.concat(`Item ${todos.length}`) });
  };

  render({ page }, { todos = [] }) {
    return (
      <div className="app">
        <style jsx>`
          .app {
            padding: 20px;
            font-size: .75rem;
          }
        `</style>
        <ul>
          <each of={todos} item="todo">
            <if condition={index > 5}>
              <li>{todo * 2}</li>
              <elseif condition={index > 10}>
                <li>{todo * 3}</li>
              </elseif>
            </if>
          </each>
        </ul>
        <button n-show={todos.length > 0} onClick={this.addTodo}>Add Todo</button>
      </div>
    );
  }
}

For above example, combining with the Babel plugin provided by NornJ, it is possible to write various new enhancement syntaxs in JSX.

  • Use NornJ tagged templates syntaxs(with styled-components, the Template Engine documents are being sorted out and released recently):
const template = html`
  <Container>
    <ul>
      <each of="{todos}">
        <if condition="{@index > 5}">
          <li>{@item * 2}</li>
          <elseif condition="{@index > 10}">
            <li>{@item * 3}</li>
          </elseif>
        </if>
      </each>
    </ul>
    <button n-show="{todos.length > 0}" :onClick="addTodo">Add Todo</button>
  </Container>
`;

const Container = styled.div`
  padding: 20px;
  font-size: 0.75rem;
`;

class App extends Component {
  addTodo = e => {
    const { todos = [] } = this.state;
    this.setState({ todos: todos.concat(`Item ${todos.length}`) });
  };

  render() {
    return template({ components: { Container } }, this.state, this);
  }
}

In the above example, a template function was created using tagged templates API of NornJ. In this way, the template can be separated from the component logic code, and it also supports more concise writing than NornJ JSX API.

Playground

Install

npm install babel-plugin-nornj-in-jsx  #or yarn add babel-plugin-nornj-in-jsx

Next, add nornj-in-jsx to plugins in your babel configuration:

{
  "plugins": [
    "nornj-in-jsx"
  ]
}

Boilerplate projects

Syntax highlight

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].