Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://arthurclemens.github.io/mithril-template-converter/
Mithril HTML to JavaScript converter
https://arthurclemens.github.io/mithril-template-converter/
mithril
Last synced: about 1 month ago
JSON representation
Mithril HTML to JavaScript converter
- Host: GitHub
- URL: https://arthurclemens.github.io/mithril-template-converter/
- Owner: ArthurClemens
- Created: 2016-02-05T17:23:53.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2023-02-12T11:10:22.000Z (almost 2 years ago)
- Last Synced: 2024-10-29T00:53:16.238Z (about 2 months ago)
- Topics: mithril
- Language: JavaScript
- Homepage: https://arthurclemens.github.io/mithril-template-converter/
- Size: 10.5 MB
- Stars: 91
- Watchers: 4
- Forks: 26
- Open Issues: 19
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-mithril - Mithril Template Converter - Convert HTML to `m()` hyperscript. (Uncategorized / Uncategorized)
README
# Mithril HTML to JavaScript converter
## Online converter
[Open online converter](http://arthurclemens.github.io/mithril-template-converter/index.html)
## Template Builder
Helper function to create Mithril templates from HTML. Use the output text to copy-paste into your source code.
```javascript
/**
* @param {object} opts
* @param {string} opts.source - String containing HTML markup
* @param {("2" | "4" | "tab")} opts.indent - Indent spacing
* @param {("double" | "single")} opts.quotes - Quotes
* @param {("attributes" | "selectors")} opts.attrs - Display of attributes
* @returns {string}
*/
const resultString = templateBuilder(opts)
```### Usage in modules
```javascript
import { templateBuilder } from "mithril-template-builder"const source = `
Mithril website: Mithril website
`
const output = templateBuilder({
source
})
```Output:
```javascript
m("p",
[
"Mithril website: ",
m("a", {"href":"http://mithril.js.org"},
"Mithril website"
)
]
)
``````javascript
import { templateBuilder } from "mithril-template-builder"const source = `
Mithril
`
const output = templateBuilder({
source,
indent: "4",
attrs: "selectors",
quotes: "single",
})
```Output:
```javascript
m('a[href="http://mithril.js.org"]',
'Mithril'
)
```## App
Contains source code for the [online converter](http://arthurclemens.github.io/mithril-template-converter/index.html).
Helper patterns and libraries:
* [Meiosis](http://meiosis.js.org)
* [Patchinko](https://github.com/barneycarroll/patchinko)
* [Polythene](http://polythene.js.org)