Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2
An alternative to Vue template and Vue JSX
License
NotificationsYou must be signed in to change notification settings
egoist/vue-html
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Use tagged template string in Vue.js render function
If you want to use Vue without a bundler / transpiler, this library will (reasonably) make your app smaller:
- Vue (runtime + template compiler): 32kB gzipped
- Vue (runtime + vue-html): 23kB gzipped
What's the downside? No handy sugars likev-model
support.
$ npm install --save vue-html
CDN versions:
UMD
:https://unpkg.com/vue-html/dist/html.js (exposed aswindow.HTML
)ESM
:https://unpkg.com/vue-html/dist/html.es.js
importVuefrom'vue'importHTMLfrom'vue-html'Vue.use(HTML)constTodos={props:['todos'],render(html){returnhtml`<ul>${this.todos.map((todo,index)=>{returnhtml`<likey=${index}>${todo}</li> `})}</ul> `}}newVue({el:'#app',data:{todos:['Conquer the world','Rewrite Peco'],todo:''},methods:{add(){this.todos.push(this.todo)this.todo=''}},render(html){returnhtml`<div><inputvalue=${this.todo}onInput=${e=>(this.todo=e.target.value)}/><buttontype="button"onClick=${this.add}>Add</button><hr/><${Todos}todos=${this.todos}/></div> `}})
The usage is very similar to Vue JSX except that thehtml
function is powered byHTM (Hyperscript Tagged Markup).
constApp={render(html){returnhtml`<div><${Todos}/><${Todos}> or with children<//></div> `}}
You can also use the traditional way of using local / global components:
constApp={render(html){returnhtml`<div><Todos/></div> `},components:{ Todos}}
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
About
An alternative to Vue template and Vue JSX
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.
Packages0
No packages published
Uh oh!
There was an error while loading.Please reload this page.