Installations
npm install hyperscript-markup
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
6.9.1
NPM Version
3.10.8
Score
74
Supply Chain
99
Quality
74.9
Maintenance
100
Vulnerability
100
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
Love this project? Help keep it running — sponsor us today! 🚀
Developer
dfadev
Download Statistics
Total Downloads
1,315
Last Day
5
Last Week
6
Last Month
23
Last Year
86
GitHub Statistics
11 Commits
2 Watching
1 Branches
1 Contributors
Bundle Size
7.64 kB
Minified
2.64 kB
Minified + Gzipped
Package Meta Information
Latest Version
1.0.2
Package Id
hyperscript-markup@1.0.2
Size
13.96 kB
NPM Version
3.10.8
Node Version
6.9.1
Total Downloads
Cumulative downloads
Total Downloads
1,315
Last day
0%
5
Compared to previous day
Last week
0%
6
Compared to previous week
Last month
187.5%
23
Compared to previous month
Last year
-36.8%
86
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dev Dependencies
5
hyperscript-markup
This is a Babel plugin that transpiles markup into hyperscript. Compatible with any hyperscript library that accepts hyperscript in the form of hyperscriptFunction(tag, attributes, [children])
. Works with React, Mithril, and Hyperapp.
Template Syntax
Views are declared by the magic sequence $>
. This will transpile the template that follows it into hyperscript calls.
You can specify which hyperscript function to call like this:
$>
-- Transpile toReact.createElement()
.$m>
-- Transpile tom()
.$h>
-- Transpile toh()
.$yourFunc>
-- Transpile toyourFunc()
.
1const view = $> 2 (div.intro) 3 (ul) 4 (li > 'Some') 5 (li > 'List items') 6 (ul.another-list) 7 (list => item) 8 (li > item) 9 (form) 10 (input(type="text", value = "Text value", onfocus = focus)) 11 (input(type="checkbox", required=true) 12 ('Check this') 13 14ReactDOM.render(view, document.getElementById('react-app'))
Elements
Any html element can be expressed in parentheses:
1(img)
CSS classes can be set using the .
operator:
1(img.my-class-name.my-other-class-name)
An element id can be set with the +
operator (as # wouldn't be valid haxe syntax):
1(img+my-id)
Attributes can be used inside the selector:
1(img(src="img.jpg"))
Attributes can also be expressed separately:
1(img(src="img.jpg", alt="")) 2(img(src="img.jpg", aFunctionCallReturningAttributes()))
A component needs to have it's first letter capitialized:
1(div) 2 (MyComponent(param=1)) 3 (MyOtherComponent(param=2))
Children
A shortcut for defining one child:
1(h1 > 'My title')
More than one child can be nested by using indentation:
1 (nav) 2 (ul.links) 3 (li) 4 (a(href="http://haxe.org") > 'Haxe') 5 (li) 6 (a(href="http://github.com") > 'Github')
Inline expressions
Strings and template strings are supported.
1(h1) 2 ('A string for example') 3(button) 4 (`${this.buttonLabel}`)
Prefix an expression or identifier with the tilde operator ~
to embed an expression without a call to the hyperscript functor.
1(div) 2 (~expression)
Would translate to:
1React.createElement('div', {}, expression)
Conditionals
$if
, $elseif
, and $else
can be used inside templates:
1($if (headerSize == 1)) 2 (h1 > 'Big') 3($elseif (headerSize == 2)) 4 (h2 > 'Not that big') 5($else) 6 (p > 'Paragraph')
Map
The following syntax can be used for any object (in this case links
) with a map method:
1(links => link) 2 (a (href=link.url, target='_blank') > link.title)
Map with null check
Using the >>
operator adds a null check prior to map execution.
1(links >> link) 2 (a (href=link.url, target='_blank') > link.title) 3
Translates to:
1if (links != null) 2 links.map(function(link) React.createElement('a', { href: link.url, target: '_blank' }, [ link.title ]); 3else 4 [];
Sample
An example can be found at examples/simple
.
Initial build:
1cd examples/simple 2npm install 3npm run build 4cd htdocs 5see index.html
![Empty State](/_next/static/media/empty.e5fae2e5.png)
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
Found 0/11 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no SAST tool detected
Details
- Warn: no pull requests merged into dev branch
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Score
3
/10
Last Scanned on 2025-02-03
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More