Jswalker Ajax is damn easy and useful it is built around plain javascript ajax wrapper
jswalker_obj.wire({ url:"url",type:"POST",ziel:{hello:"Hi jswalker"},
success:function(success_op){
console.log(success_op);
},
fail:function(fail_op){
console.log(fail_op);
}
});
Wire
Function to use ajax library
urlNo need to explain : pass url with controller and method combination
typeType of request : default is post
zielZiel : is represent data in jswalker
Jswalker Booster responsible for call socket code : only difeference with wire and booster is that wire call controller/model fashion but booster call direct model
jswalker_obj.booster({ model:"model-name",method:"method=name",ziel:{hello:"Hi jswalker"},
success:function(success_op){
console.log(success_op);
},
fail:function(fail_op){
console.log(fail_op);
}
});
booster
Function to use socket library
modelDirect model name in jswalker
methodMethod name inside model
zielZiel : is represent data in jswalker
success_op contain following object :
{
status:{ flag:"success" , info:""} ,
ziel:{ hello:"Hi from jswalker server"}
}
Fail
fail_op contain following object :
{
status:{ flag:"fail" , info:{
controller_name:"controller-name",
controller_line_number:101,
model_name:"model-name",
model_line_number:101,
trace_line:"#c(controller-name)"
error_stack:"Full Error Stack"
},
ziel:{}
}
Rendering process of jswalker cut down into two parts
Note: This processs is very crucial and hard to understand because
it is directly affect the rendering speed and performance ,
Recommanded way is to understand demo code and try to understand from direct code
and get idea of every chunk of code in documentation.
---
layout: render/demo/demo.html
title: Jswalker demo project
---
<!-- Head block -->
[[##head:
<head>
<title>[[= layout.title ]]</title>
<link rel='stylesheet' href='[[=model.base.css]]/demo.css' />
</head>
#]]
<!-- Head block -->
<!-- Common block -->
[[##header:
[[= partial('render/common/header.html') ]]
#]]
<!-- Common block -->
<!-- Script block -->
[[##script:
<script type='text/javascript' src='[[=model.base.js]]/jswalker-core.js' ></script>
<script type='text/javascript' src='[[=model.base.js]]/jquery-2.2.4.js' ></script>
<script type='text/javascript' src='[[=model.base.js]]/demo.js' ></script>
[[= partial('render/demo/demo.js') ]]
#]]
Top level
Three dash line ---
on top of html page is very crucial
inside this block tells the dot parser where to push this layout in this case view/render/hello/hello.html
Every layout values now dump here
<html>
[[=layout.head]]
<body>
<div>
[[=model.data.value]]
</div>
</body>
[[= layout.script]]
</html>
Note: Script file also include here which contain dynamic dot template engine
Contain dot scripts are reside here related to page
Note: Only difference here is that
sever side template engine denoted with [[
client template denoted with {{
try{
dot_obj.chunk['demo_init']="{ for(var i=0;i<it.length;i++) { }}"+
"<p>Test value : {{=it[i].test_value}} </p>"+
"<p>Test string : {{=it[i].test_string}} </p>"+
"{{ } }}";
}catch(err){
console.log(err);
}
var data=[
{test_value:1,test_string:'hi'},
{test_value:2,test_string:'hi'}
]; // Suppose this variable contain data which came from server
var demo_template=doT.template(dot_obj.chunk['demo_init']); // get template chunk and compile in function
var html=demo_template(data); // pass data into cimpiled function
$("body").html(html); // Push html content to body