Giter Club home page Giter Club logo

html2mithril's Introduction

html2mithril

This is a small library that is intended to be used with gulp to convert raw html files into Mithril's view.js files.

The majority of the code is from Leo Horie (https://github.com/lhorie). Original code from Leo was a web page that converted html string (http://lhorie.github.io/mithril/tools/template-converter.html). This script converts the web based version for use in gulp. Use example in gulp

gulp.task('html2mithril', function() {
    // gulp.src -- get html template
    return gulp.src("./header/text.html")
        // pipe through plugin
        .pipe(mithrilify("object", "postRender"))
        //Rename file as view.js
        .pipe(rename('./header/view.js'))
        // set destination
        .pipe(gulp.dest('./'))
});

You can watch for changes in the file or files with gulp watch.

var paths = {
    htmlfile : './header/text.html'
};

gulp.task('watch', function() {
    gulp.watch(paths.htmlfile, ['html2mithril']);

});

gulp.task('default', ['html2mithril', 'watch']);

It takes two arguments :

object (string)

The module object that the view binds to. for example if your mithril structure is like this:

var header = {}
header.controller = function(){}
header.view = function(){} 

In this case your object is a string called "header".

postRender (string)

If you would like to run a function for rendering when div is loaded you can add it into the wrapper div element. This will appear as :

m('div', {config: postRender, [ m(...)])

html2mithril's People

Contributors

caneruguz avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.