Server-side isscript blocks and SFRA page asset registration
Key Takeaway
All <isscript> blocks in one ISML template share one execution context, so a variable declared in one block works in later blocks and in ${ } expressions. In SFRA, the recommended use of <isscript> is to register a page's client-side JavaScript and CSS through the assets module.
An <isscript> block runs server-side script inside an ISML template. ${ } expressions let you use script values inline in the page or inside tag attributes. In SFRA, the recommended use of <isscript> is narrow. Each page template uses it to register its client-side JavaScript and CSS files through the assets module, while business logic stays in controllers and models.
Server-side script in a template
An <isscript> ... </isscript> block holds server-side script inside an ISML template. You can put the block in <head>, in <body>, or anywhere a script tag is valid.
Four top-level variables are available inside an <isscript> block:
| Variable | What it is |
|---|---|
session | The current session (dw.system.Session) |
request | The current request (dw.system.Request) |
pdict | The Pipeline Dictionary (dw.system.PipelineDictionary) |
out | A PrintWriter for the HTML page |