Skip to content

Instantly share code, notes, and snippets.

# New validation
validation = new Validator()
# Datas to validate
datas =
name: 'Batman'
# Rules of validation to use
rules =
name: 'required|length:6'
route.match '/tweet', ->
syphon = new Syphon()
tweet = syphon.exclude('title').get('#tweet')
# Will log the json
#
# {
# nickname: "batman"
route.match '/tweet', ->
syphon = new Syphon()
tweet = syphon.get '#tweet'
# Will log the json
#
# {
# title: "My super tweet",
<form id="tweet">
<input type="text" name="title" value="My super tweet" />
<input type="text" name="nickname" value="batman" />
</form>
jsonObject =
"name": "batman"
"lvl": "25"
<form id="new">
<input type="text" name="name" value="batman" />
<input type="text" name="lvl" value="25" />
</form>
Controller = require 'core/controller'
Class Robin extends Controller
run: ->
user =
name: 'robin'
# Load a view
# Don't forget to put that line in the top of the file
View = require 'core/view'
route.match '/users', ->
# Our user
user =
name: 'Batman'
lvl: 25
<div class="user">
<span class="user-name"><%- @name %>, level <span class="user-lvl"><%- @lvl %></span>
</div>
route.match '/users', ->
user =
name: 'Batman'
lvl: 25
block = '<div class="user"><span class="user-name">' + user.name + '</span>, level <span class="user-lvl">' + user.lvl + '</span></div>'
$('body').html block