SFRA Code Quick Card: 'Use Strict' 'Server' 'Start'
SFRA Code Quick Card: 'Use Strict' 'Server' 'Start'
BASIC FUNCTION
'use strict';
//other imports here…
var server = require('server');
var server = require('server');
server.extend(module.superModule);
server.prepend('Show', function (req, res, next) {
//This information is inserted before the original Show Route.
});
server.append('Show', function (req, res, next) {
//This information is inserted after the original Show Route.
});
server.replace('Start', function (req, res, next) {
//This information replaces the original Start Route.
});
server.get('Show', function (req, res, next) {
//gets the querystring parameters from req
var params = req.querystring;
//gets the product from ProductFactories
var theProduct = VariableName.get(params);
//…
});
TEMPLATE DECORATOR
<isdecorate template="common/layout/templatename">
</isdecorate>
LOCAL INCLUDE
<isinclude template="templatename"/>
REMOTE INCLUDE
<isinclude url="${URLUtils.url('ControllerName')}" />
CONTENT SLOT
<isslot id=".." description="..." context="..." />
FORM METADATA
<field formid="..." label="..." type="..." binding="..." />
FORM ISML
<div class="form-group notrequired">
<label class="form-control-label">
<isprint value="${pdict.parameter}" encoding="htmlcontent" />
</label>
<input type="checkbox" class="form-control" id="..." <isprint value="${pdict.param
</div>
var scriptName = require('*/cartridge/scripts/scriptName');
server.get('Show',scriptName.function,
function (req, res, next) {
res.render('templatename');
next();
});