node lift
dual side templating, made easy.
this library simplifies templating by lifting parts of a template to the client. these parts will be processed, when the client got all data.
installation
npm install lift
server side api
LiftState
LiftState = lift =
it actually returns a function, so lift
is callable.
the LiftState instance can be accessed via lift.self
.
lift
static_args
arguments defined on server sidedynamic_args
arguments given on client sidedata
given on client side
this defines a function that can run on server or client (decision can be made per request by calling lift.direct
or lift.get
before).
it is best used in the views to define lazy template parts.
lift.direct
lift
sets the arguments of given id
-part. when id
-part gets defined it will be called direct.
useful to render parts on server side.
lift.get
lift;
define a function that will be invoked with the requested id
-part.
useful to render parts on server side.
lift.code
client_side_code = liftcode // or LiftState.code()script_tag = '<script type="text/javascript">' + client_side_code + '</script>'
returns client side code. only needed once per request.
client side api
window.lift
lift || windowlift // same
this is the client side of the library. it returns from LiftState.code()
.
window.lift.call
lift
dynamic_args
arguments defined on client sidedata
defined on client side
this invokes the id
-part at the client defined on server side.
window.lift.get
fun = lift
dynamic_args
arguments defined on client sidedata
defined on client side
similar to window.lift.call
but just returns a function containing all server and client side arguments and the id
-part.
window.lift.DEBUG
lift
it prints the context to the console. the context contains every function and its arguments defined by calling lift
on server side.
NOTE
this library does not specify on which channels (socket.io, ajax, comet, jsonp, etc …) the data is passing to the client.
example
the example server should explain everything else.
influenced by lifts lazy load idea.