kScript is the programming language inside Kooboo. It support full JavaScript ES5 syntax with an additional k object. 

kScript can be used to do full web programming task, and extend the functionality of kooboo. It can do similar things as your normally do with PHP or JSP. 

Embedded Script

You can embedded kScript in your view html code, use it like PHP or other web languages, but with JavaScript syntx. You only need to add the "engine=kscript" attribute to the Script tag.  Below code read all item from database and render the items with template. 

<script engine=kscript> 
    var list = k.database.getTable("tablename").all(); 
<div k-foreach="item list">
    <h2 k-content="item.title">Welcome!</h2>
    <p k-content="item.summary">Welcome to Kooboo CMS</p> 

For reference of kScript, see coding reference charpter. 

Types of Backend Script

Navigate to "Development" -- "Code". 

You can use kScript to write many type of codes. 

Api:  Response to client API request, contains a route and response Json.

Datasource:  Used on view designer, to provide data source for view binding. 

Diagnosis:  Used on Diagnosis option to check your website errors. 

Event: Used on the Event IF THIS THEN THAT rules. 

Job: Schedule task to run on your system. 

PageScript: Similiar like a normal Script, but run on server side, with both external and embedded objects.

Sample code

Click "Create" and select one type of script to create. 

There some sample code provided with each type, so that you understand what you can do there. 

Code configuration

Some type of code may have configuration, for example, event and datasource. 

Click "Configuration" in the button, switch to configuration and follow the sample code to export a config object. 

kScript reference

On the left side of coding windows, there is a kScript reference document

Click the button on left top corner of the reference windows, open the reference object list. 

Click on each object to go to reference of that object.