Mithril Template Converter Save

Mithril HTML to JavaScript converter

Project README

Mithril HTML to JavaScript converter

Online converter

Open online converter

Template Builder

Helper function to create Mithril templates from HTML. Use the output text to copy-paste into your source code.

/**
 * @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

import { templateBuilder } from "mithril-template-builder"

const source = `
<p>Mithril website: <a href="http://mithril.js.org">Mithril website</a></p>
`
const output = templateBuilder({
  source
})

Output:

m("p",
  [
    "Mithril website: ",
    m("a", {"href":"http://mithril.js.org"}, 
      "Mithril website"
    )
  ]
)
import { templateBuilder } from "mithril-template-builder"

const source = `
<a href="http://mithril.js.org">Mithril</a>
`
const output = templateBuilder({
  source,
  indent: "4",
  attrs: "selectors",
  quotes: "single",
})

Output:

m('a[href="http://mithril.js.org"]', 
    'Mithril'
)

App

Contains source code for the online converter.

Helper patterns and libraries:

Open Source Agenda is not affiliated with "Mithril Template Converter" Project. README Source: ArthurClemens/mithril-template-converter
Stars
91
Open Issues
19
Last Commit
1 year ago
Tags

Open Source Agenda Badge

Open Source Agenda Rating