Wiki

Clone wiki

slan / Home

Tour

Features

  • HTTP-to-code url mapping
  • Bind an HTTP parameter to a code method parameter
  • Hot reload(fix the bug and hit reload)
  • Show error source code directly
  • Simple stateless MVC
  • Familiar templating engine(the language just is fantom)
  • Standalone architecture(all pod is standalone)
  • Javascript FWT suppert
  • Zero configuration
  • Build-in localization
  • Fanlet compatible(to deploy on servlet container)
  • Full-stack(ORM/Validate/Patchca...)

Overview

  • slanWeb is core web service
  • slanDemo is a web app template and demo
  • slanOrm is very simple ORM tool
  • slanUtil is some web utilitys

Quickly start

Down load and build slanWeb and slanUtil.

Run slanDemo on dubug mode:

$fan idraft -appHome file:/D:/code/Hg/slan/slanDemo/ slanDemo::RootMod

You should be able to hit http://localhost:8080/ with your browser!

Directory Structure

fan
  -action //your app controller
  -jsfan //javascript fwt class
  -model //app model
  -boot //webRootMod and Main
  -util
public
  -image
  -javascript
  -stylesheet
  -favicon.ico
  -error.html
res
  -fwt //fwt segment
  -view //template file
test
locale //i18n
build.fan

First Action

Create a new class in action folder, like this:

fan/action/Hello.fan

   using slanWeb
   using web
   const class Hello : SlanWeblet
   {
      Str say(Str name)
      {
         "Hello $name"
      }
   }

Do not need to restart the service.

Go to http://localhost:8080/Hello/say?name=world. If everything is ok,you will see 'Hello world'

Add View

create a file 'say.html' in `view/Hello/`, like this:

view/Hello/say.html

<html>
  <head>
    <title>Welcome</title>
  </head>
  <body>
   #for(Int i := 0; i < 5; i++){
   <h1>@message</h1>
   #}
  </body>
</html>

and modify above action code to:

   using slanWeb
   using web
   const class Hello : SlanWeblet
   {
      Void say(Str name)
      {
         m->message = "Hello $name"
         render
      }
   }

'm' be use to pass data from controller to view

Refresh your browser, you will see the message five times.

Work with FWT

There are two way to work with FWT.

1. Embed into HTML page

   m->compileJs = compileJs(`Hello.fwt`)

And insert a div in HTML code

  <div id='fwt-root' style='position:relative; width:400px; height:300px;'>
  </div>

2. Full FWT

Add a class at appHome/fan/jsfan/. And mark it using js facet.

SlanBlog

Yet another blog base on Slan https:bitbucket.org/chunquedong/slanblog

Updated