npm installation and usage - metincetin/Karbid GitHub Wiki
You can install karbid with npm and and use it on node apps.
npm install karbid
to use it on node app require the karbid module
var karbid = require("karbid")
Properties
karbid.render(code,data)
renders the karbid code in client, sending the specified data
karbid.renderFile(path,data)
renders the karbid file in client, sending the specified data.
karbid.options.head
head tag for the page. <meta charset="utf8">
by default
karbid.options.jsPath
path of karbid javascript file. __dirname+"src/karbid.min.js"
by default
karbid.options.vars
the object the data stored in. window
by default
Express example
var express = require('express')
var app = express()
var karbid = require('karbid')
var x = "Hello world"
var y = "This is karbid."
app.get("/",function(req,res){
res.send(karbid.render(`
@h1{
html:"Rendered karbid code:"
}
@{
html:var1+ " - "+var2
}
`,{var1:x,var2:y}))
})
//rendering file
app.get("/file",function(req,res){
res.send(karbid.renderFile("helloWorld.kd",{var1:x,var2:y}))
});
app.listen(4000,function(){
console.log("Listening")
})