FerrugemJS
###A simple library, reactive, conventional and non-intrusive!
#####install
jspm install npm:ferrugemjs
#####how start
in your index.html file
<body>
<div app></div>
<script>
System.import("ferrugemjs");
</script>
</body>
###conventional
FerrugemJS will look for the first page element with the attribute "app" to boot and if you encounter will not use the tag "body".
Just create app.js files and app.html in the same directory of the index.html page.
If you want to modify the path of the file app.js just add this information to the app attribute as below:
<div app="other_path/other_init_app_file"></div>
###non-intrusive
your app.js file.
class MyBasicApp{
constructor(){
this.title = "ferrugemjs";
}
}
export default MyBasicApp;
Yes, without any interference from the library. Its simple class using only "javascript 2015".
###simple
your app.html file.
<template args="$controller">
<h1>My First APP with {$controller.title}</h1>
</template>
###reactive
class MyBasicApp{
constructor(){
this.title = "ferrugemjs";
}
attached(){
setTimeout(()=>{
this.title = "change by a settimeout";
//a reactive update after a time
this.refresh();//using the "refresh" method, the only injectable method by the library.
},4000);
}
}
export default MyBasicApp;
###importing other modules
create your second module in file "hello-world.js"
class HelloWorld{
constructor(){
this.name = "";
}
//by convention as the "name" attribute is modified the method to "on" + "attribute name" + "Changed" is called.
onNameChanged(new_name,old_name){
this.refresh();
}
}
export default HelloWorld;
create your second html module in file "hello-world.html"
<template args="$controller">
<h2>Hello World, {$controller.name}</h2>
</template>
import the hello-word modulo into your app.html
<template args="$controller">
<h1>My First APP with {$controller.title}</h1>
<require from="hello-world"></require>
<hello-world name="C-3PO"></hello-world>
</template>
you can also give an alias for your module.
<template args="$controller">
<h1>My First APP with {$controller.title}</h1>
<require from="hello-world as sea-bienvenido"></require>
<sea-bienvenido name="C-3PO"></sea-bienvenido>
</template>
###module lifecycle
#####constructor: The natural way in which the object is created in javascript.
#####attached: By implementing the method your module will be prompted for it once the html is in "DOM".
#####on+attribute name+Changed:By implementing the method with the module attribute in CamelCase format your module will be notified when there is any change to the way template attribute