Registry / web-framework / mithril-template

mithril-template

JSON →
library0.0.1jsnpmunverified

HTML to Mithril hyperscript transpiler that converts HTML templates into Mithril's virtual DOM hyperscript (m()) calls. Version 0.0.1, early stage, no formal release cadence. Supports interpolation (mustache syntax), binding attributes with colon prefix, component embedding (kebab-case to camelCase), and directives (if/elseif/else/for). Differentiates from similar tools by its directive system and non-standard component naming conventions. Limited documentation and no ongoing maintenance observed.

npm install mithril-template
INSTALL
IMPORT
SIG · MITHRIL-TEMPLATE
M
mithril-template
web-frameworkjavascriptv0.0.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

mithrilTemplate
var mithrilTemplate = require('mithril-template')
import mithrilTemplate from 'mithril-template'
CommonJS only; no ES module export. Use require() as shown.
mithrilTemplate (named no default)
const { compile } = require('mithril-template')
import { compile } from 'mithril-template'
No named exports in v0.0.1; only default export is a function. This is a placeholder.
Global usage
<script src='mithril-template.js'></script>
import mithrilTemplate from 'mithril-template'
Not distributed as standalone script; only Node require() pattern works.

Converts an HTML template string with interpolation to Mithril hyperscript function call.

var mithrilTemplate = require('mithril-template'); var hyperscript = mithrilTemplate('<h1 class="greetings">Hello {{ name }}!</h1>'); console.log(hyperscript); // m('.greetings','Hello '+name+'!')
Debug
Known issues
breakingNo ES module support; only CommonJS require() works.
fix
Use require() instead of import.
affects: 0.0.1
gotchaComponent tags must end with '-component' and cannot be self-closing.
fix
Write <custom-component></custom-component> not <custom-component />.
affects: 0.0.1
gotchaMustache interpolation {} cannot be used inside HTML tag definitions.
fix
Use binding attribute syntax with colon, e.g., :key="foo" instead of key="{{ foo }}".
affects: 0.0.1
gotchaLiteral { and } characters in templates must be escaped using interpolation workaround.
fix
Use {{ '{' }} and {{ '}'+'}' }} or similar string concatenation.
affects: 0.0.1
deprecatedPackage is unmaintained; no updates since initial release.
fix
Consider alternatives like mithril-node-render or custom source transform.
affects: 0.0.1
gotchaHTML attributes not prefixed with colon are omitted when used on component tags.
fix
Prefix data-bound attributes with colon: <custom-component :class="'custom-class'"></custom-component>.
affects: 0.0.1
Errors
Common errors & fixes
Cannot find module 'mithril-template'
Package not installed or import path wrong.
fix
Run 'npm install mithril-template' and use require('mithril-template').
Unexpected token 'export'
Attempted ES import on CommonJS module.
fix
Use const mithrilTemplate = require('mithril-template') instead of import.
Compile is not a function
Assuming named export instead of default.
fix
The default export is the compile function. Use const compile = require('mithril-template').
Upgrade
Version history
0.0.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources