This is a proof of concept for building templated dynamic components using Stencil and <template>
tags. It is inspired by React context and Stencil Context.
The whole is inspired by Vue. The goal is to create templates that can render dynamically but are valid HTML.
JSX, Handlebars, Mustache, Jinja, Liquid, ICU (ReactIntl, Vue I18n), JSONata, and other languages for dynamically accessing data and building components and strings are fantastic technologies, but they fail the web component test. They are not valid HTML.
Why use templates based on valid HTML?
- Tooling is easier
- WYSIWYG Editors (e.g. TinyMCE, GrapesJS, etc.)
- Testing (e.g. JSDom )
- Translation tools (e.g. Transifex)
- Linting and validation
- Everyone already knows HTML
- Simple toolchain
- Just Stencil.js, can be rendered anywhere. No need for multiple layers. No need for pre-compilation.
- Part of the HTML specification
<slot>
tags don't work when you need a component rendered multiple times.- Good browser support
- Supported Polyfills
To run this example clone this repo and run:
npm install
npm start
To build the component for production, run:
npm run build
To run the unit tests for the components, run:
npm test
Need help? Check out our the Stencil Documentation.
These components have not been published, and cannot be used outside of cloning this repository.
Stencil is a compiler for building fast web apps using Web Components.
Stencil combines the best concepts of the most popular frontend frameworks into a compile-time rather than run-time tool. Stencil takes TypeScript, JSX, a tiny virtual DOM layer, efficient one-way data binding, an asynchronous rendering pipeline (similar to React Fiber), and lazy-loading out of the box, and generates 100% standards-based Web Components that run in any browser supporting the Custom Elements v1 spec.
Stencil components are just Web Components, so they work in any major framework or with no framework at all.