Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/heapwolf/to-ml
[deprecated] A tiny module to generate markup
https://github.com/heapwolf/to-ml
Last synced: 25 days ago
JSON representation
[deprecated] A tiny module to generate markup
- Host: GitHub
- URL: https://github.com/heapwolf/to-ml
- Owner: heapwolf
- Created: 2013-06-22T14:08:07.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2014-01-25T13:52:14.000Z (almost 11 years ago)
- Last Synced: 2024-10-18T17:11:34.378Z (26 days ago)
- Language: JavaScript
- Homepage:
- Size: 197 KB
- Stars: 14
- Watchers: 6
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# NOTE
In the real world, I recommend **NEVER** building an app with a tool like this for two main reasons: 1.
- Generating markup programmatically **completely** violates the separation of concerns principle.
- It's hostile toward project members who do not have Javascript in their skillset.# SYNOPSIS
A small library to generate markup.# DESCRIPTION
Generating markup can get ugly, the mix of html and javascript can
get very confusing very quickly. This little library helps you create
readable code. It also has no dependencies on the DOM so you can use
it on your node.js server.# USAGE
```js
var template = require('to-ml')().template
``````js
template(function() {
return div('hey!',
span('this is',
b('easy')
)
})
``````html
hey!this iseasy
```### IDs and Classes
If a string value matches the pattern used to create `IDs` and `classes`, they
will be automatically generated.```js
a('#home.primary.link', 'home', { href: '/' })
``````html
home
```The pattern to determine if a string value passed to a tag function is special
looks like this...```
'[#id][.class1[.class2[...]]]'
```### Adding attributes
Just add an object to the arguments, doesnt mater what order it's provided in.
```js
textarea('hey!', { 'data-id': 'greeting' })
``````html
hey!
```### When there are no params
```js
header(
br,
h1('Hello, World!')
hr,
br
),
``````html
Hello, World!
```