Internet Store Markup Language (ISML)
ISML Templates
Internet Store Markup Language or ISML templates are files with an extension of .isml which define how data, tags and page markup are transformed into HTML that is sent to the browser, using CSS for page layout and styling.
The Demandware platform uses templates to generate dynamic HTML-based Web pages for responses sent back (响应发送返回) to the client. Templates are created using Internet Store Markup Language (ISML) tags and expressions.
Describing a Demandware application using Model-View-Controller pattern, templates =>"view", pipelines =>"controller" and the DW, Script API =>"model".
create an ISML template
File ->New ISML Template
ISML Tags and Expressions
ISML tags are Demandware proprietary extensions to HTML that developers use inside ISML templates. ISML tags and expressions cannot be written in any other file other than (除了) ISML templates.
ISML tags are SGML-like extension tags that start with is, e.g. <isprint> and describe, together with regular HTML, how dynamic data will be embedded (嵌入) and formatted on the page.
ISML tags can be divided into the following groups
HTTP-related :
-
<iscookie>
Sets cookies in the browser
-
<iscontent>
Sets the MIME type
-
<isredirect>
Redirects browsers to specific URLs
-
<isstatus>
Define status codes
Flow Control :
-
<isif>
Evaluates a condition
-
<iselse> <iselseif>
Specifying alternative logic
-
when an <isif> condition does
not evaluate to true.
-
<isloop>
Creates a loop statement
-
<isnext>
Jumps to the next iteration in a
loop statement
-
<isbreak>
Terminates loops
Variable-related :
-
<isset>
Creates a variable
-
<isremove>
Removes a variable
Include :
-
<isinclude>
Includes the contents of one template on the current template
-
<ismodule>
Declares a custom tag
-
<iscomponent>
Includes the output of a pipeline on the current page
Scripting :
-
<isscript>
Allows Demandware Script execution inside templates
Forms :
-
<isselect>
Enhances(增强) the HTML <select> tag
Output :
-
<isprint>
Formats and encodes strings for output
-
<isslot>
Creates a content slot
Others:
-
<iscache>
Caches a page
-
<iscomment>
Adds comments
-
<isdecorate>
Reuses a template for page layout
-
<isreplace>
Replaces content inside a decorator template
Active Data :
-
<isactivedatahead>
Allows collection of active data from pages with a <head> tag
-
<isactivecontenthead>
Collects category context from a page for active data collection
-
<isobject>
Collects specific object impressions/views dynamically
ISML Expressions
ISML Expressions are based on the Demandware Script language. Since Demandware Script implements the ECMAScript standard, access to variables, methods and objects is the same as using JavaScript.
ISML expressions are embedded inside ${…} to allow the ISML processor to interpret (解释) the expression prior to(优先于) executing an ISML tag or the rest of the page. ISML expressions provide access to data by using dot notation. Here is an example of accessing a property of the Product object in the pipeline dictionary:
${pdict.Product.UUID}
The difference between this ISML expression and one used inside a pipeline node property (i.e. decision node) is that in ISML you must specify the ${pdict.object.property} if you want to access a value in the pipeline dictionary, whereas inside pipeline node properties the access to the pdict is implicit(隐式) and the ${} not used : i.e. Product.UUID
ISML expressions can also access Demandware Script classes and methods. Some packages are available implicitly, so classes do not need to be fully qualified:
1. TopLevel package: session. getCustomer()
2. dw.web package: URLUtils.url(), URLUtils.webRoot()
Other access to classes and methods must be fully qualified:
dw.system.Site.getCurrent()
ISML expressions can also allow complex arithmetical (复合算数), boolean and string operations:
${pdict.Product.getLongDescription() != null}
IMPORTANT NOTE
Although there are some ISML tags that do not need a corresponding (相应的) closing </> tag (i.e.: the <isslot> tag), it is best practice to always use a closing tag.
Creating and Accessing Variables: <isset>
You can create and access your own custom variables in an ISML template by using the <isset> tag (to create and access variables in Demandware Script)
When using the <isset> tag, the required attributes that must be assigned are name and value. The default scope is session, so you must be careful to qualify your variables accordingly if you do not want them.
Example:
<isset
name = "<name>"
value = "<expression>"
scope = "session"|"request"|"page"
>
The value attribute can be either a hardcoded string or number or an ISML expression accessing another variable or object:
string: value=”hardcoded text”
expression: value=”${pdict.Product.name}”
The scope attribute of a variable refers to the level of accessibility of the variable. The three available levels to you as a developer are session, request, and page.
Variable Scope
Demandware offers the following scopes, listed here from widest to narrowest access (从大到小). It is important to understand the different scopes of a variable and what objects can access a variable at each level.
-
Global Preferences:
accessible via the dw.system.OrganizationPreferences class. Available to any site within an organization.
-
Site Preferences:
accessible via the dw.system.SitePreferences class. Available to any pipeline executing as part of a site.
-
session:
available through the whole session.
-
pdict:
available while a pipeline executes. It might encompass (包含) multiple requests, like when using Interaction Continue Nodes
-
request: available through a request-response cycle. Typically the same as the pipeline scope.
-
page: available only for a specific page, and its locally (本地的) included pages.
-
slotcontent: available only in the rendering template for a content slot.
-
<isloop> variable: available only inside the loop.
Session variables are available across multiple requests within a customer session. Any variable added to the session scope becomes a custom attribute of the session object. Since it is not a standard attribute it must be accessed with the session.custom qualifier:
${session.custom.myVar}
Request variables are available via the request scope. A request variable is available only for a single browser request-response cycle: it does not persist in memory for a subsequent(后来的) request. Similar to session variables, you must prefix request variables with a qualifier request.custom when accessing them:
${request.custom.myRequestVar}
Page variables are available on the current ISML page, and their scope is limited tothe current template, and any locally included templates.They are accessed without a prefix:
${pageVar}
Setting and retrieving variables
-
In the template, create a new variable called sessionVar with hardcoded textas the value and print the value to the page:
<isset name="sessionVar" value="${1}" scope = "session"/>
-
The value of the sessionVar variable is:
${session.custom.sessionVar}<br/>
-
Increment the variables by using syntax like
value="${request.custom.requestVar + 1}"
Reusing Code in Templates
There are four tags available to you as a developer for reusing code in ISML templates:
-
<isinclude> 包含标签
-
<isdecorate> 装饰标签
-
<ismodule> 自定义标签
-
<iscomponent> 组件标签
Reusable code for these purposes:
-
Saves time 节约时间
-
Reduces the likelihood of errors 减少可能的错误
-
Minimizes the chore of updating pages 最小化更新页面的工作
-
Helps to ensure a consistent look and feel 帮助确保一致性
The <isinclude> Tag 包含标签
The <isinclude> tag allows you to embed an ISML template inside the invoking template. There are two types of includes:
-
Local Include (本地包含) – allows you to include the code of one ISML template inside of another while generating the page
-
Remote Include (远程包含) – allows you to include the output of another pipeline inside of an ISML template. The primary purpose for using a remote include is for partial page caching.
Local Includes 本地包含
Local includes are heavily used throughout SiteGenesis.
The syntax for using a local include is:
<isinclude template="[directory/]templatename" />
You do not need to add the '.isml' extension when including a template.
Local Includes Example
Template 1:
<h1>My Template</h1> <br/>
<isinclude template="extras/calendar" />
Template 2 (calendar.isml)
<h1>Included template</h1>
IMPORTANT NOTE
1. Local Include - All variables from the including template are available in the included template, including page variables.
2.Remote Include -Pdict and page variables from invoking template are NOT available in the included template. The only variables
available to a remotely included pipeline are session variables.
3. Includes from another server are not supported.
Remote Includes
The syntax for a remote include is
<isinclude url="pipeline_url" />
Using a remote include in a template will invoke another pipeline which returns HTML at runtime. The examples below show how to call a pipeline without passing URL parameters:
<isinclude url="${URLUtils.url('Product-IncludeLastVisited')}" />
In the example above, the dw.web.URLUtils url() method builds a site-specific URL for the Product-IncludeLastVisited pipeline. This is a best practice sinceyou should never hardcode a pipeline URL since it would contain a specific serverin it: use URLUtils methods instead.
Here is an example of passing URL parameters:
<isinclude url="${URLUtils.url('BrowseCatalog-Hotdeals', 'catalogCategoryID', 'Storefront')}"/>
The page generated by the invoked pipeline can be dynamic or it may come from cache.
There is a new tag that implements a remote include: (组件标签)
<iscomponent
pipeline = <string> | <expression>
[locale = <string> | <expression> ]
[any number of additional arbitrarily named parameters]
/>
This tag allows you to pass as many attributes as you want without having to use the URLUtils methods:
<iscomponent pipeline ="Product-Show" productid="1234" name="Wide-screen television"/>
Reusing Code in Templates : <isdecorate> Tag
The <isdecorate> tag lets you decorate the enclosed content with thecontents of the specified (decorator) template. A decorator is an ISML template thathas html, css, and overall design of a page. The decorator template has the tag <isreplace/> identifying where the decorated content shall be included.
Typically, only one tag (<isreplace/>) is used in the decorator template. However, multiple tags can also be used. If the decorator template has multiple <isreplace/> tags, the content to be decorated will be included for each <isreplace/> tag.
A typical use case is to decorate the content body with a header and footer:
Template using a decorator :
<isdecorate template="[Decorator template name]">
...My content...
</isdecorate>
Decorator template :
<html>
<head>…</head>
<body>
<isreplace/>
</body>
<html>
Run the use <isdecorate> tag activity
1.Open the ISML template that has the code you wish to replace in a decorator. Add the <isdecorate> tag around the code you wish to include in a decorator.
<isdecorate template="[directory/]decoratorname">
Your code goes here.
</isdecorate>
2. Open the decorator template. If you are using a SiteGenesis template, the decorator templates names start with "pt_".
3. Find the location in the code where you want to use the <isreplace/> tag. Add the tag to the template.
Creating Custom Tags with <ismodule>
The <ismodule> tag allows you to define your own ISML tags.
There are three key isml files required for creating and using a custom tag:
1. The isml file which sets the values of any attributes of the custom tag. See the example below in util/modules.isml
自定义标签属性定义文件
<ismodule template="components/breadcrumbs"
name="breadcrumbs"
attribute="bctext1"
attribute="bcurl1"
attribute="bctext2"
attribute="bcurl2"
attribute="bctext3"
attribute="bcurl3"
/>
2. The isml file which specifies what happens when the attributes are passed. See the code snippet from inside breadcrumbs.isml
定义自定义标签展现方式
<isif condition="${pdict.bcurl1 != null}">
<a href="${pdict.bcurl1}" title="${pdict.bctext1}">
${pdict.bctext1}</a>
</isif>
3. Lastly, you need to invoke the custom tag inside an isml template:
调用自定义标签
<html …>
<isinclude template="util/modules"/>
<head>…</head>
<body>
…
<isbreadcrumbs bctext1="…" bcurl1="…"/>
</body>
</html>
Conditional Statements and Loops
syntax:adds "is" to the beginning of tags
<isif condition=”${ISML expression evaluated}”>
Do something here if true.
<iselseif condition=”${check another condition}”>
Do something if this one is true.
<iselse>
If none of the above conditions are true, do this.
</isif>
Loops
With <isloop> you can loop through the elements of a specified collection or array. As an example, you can list data like categories, products, shipping and payment methods. An <isloop> statement can be nested in one another.
Supporting tags
<isbreak> : can be used within a loop (defined by an <isloop> tag) to terminate a loop unconditionally. If <isbreak> is used in a nested loop, itterminates only the inner loop.
<isnext>: to jump forward in a loop. Jumping forward within a loop to the next list element of an iterator. This tag affects only the iterator of the inner loop. The syntax for using the <isloop> tag is:
<isloop
iterator|items = "<expression>"
[ alias|var = "<var name>" ]
[ status = "<var name>" ]
[ begin = "<expression>" ]
[ end = "<expression>" ]
[ step = "<expression>" ]
>
…do something in the loop using <var_name>…
</isloop>
The attributes have the following usage:
-
items (iterator)
Expression returning an object to iterate over. Attributes iterator and
items can be used interchangeably (可交换的) .
-
var (alias)
Name of the variable referencing the object in the iterative collection
referenced in the current iteration.
-
status
Name of the variable name referencing loop status object. The loop
status is used to query information such as the counter or whether it is
the first item.
-
begin
Expression specifying a begin index for the loop. If the begin is greater
than 0, the <isloop> skips the first x items and starts looping at the
begin index. If begin is smaller than 0, the <isloop> is skipped.
-
end
Expression specifying an end index (inclusive). If end is smaller than
begin, the <isloop> is skipped.
-
step
Expression specifying the step used to increase the index. If step is
smaller than 1, 1 is used as the step value.
For the status variable, the following properties are accessible:
-
count
The number of iterations, starting with 1.
-
index
The current index into the set of items, while iterating.
-
first
True, if this is the first item while iterating (count == 1).
-
last
True, if this is the last item while iterating.
-
odd
True, if count is an odd value.
-
even
True, if count is an even value.
For example, if the <isloop> tag declares a status=”loopstate” variable, then it is possible to determine the first time the loop executes by using: <isif condition="loopstate.first" >
Using Loops
1.Implement the following code to display the products in the cart
<isloop
items="${pdict.Basket.allProductLineItems}"
var="productLineItem">
${productLineItem.product.name}<br/>
</isloop>
2.Replace the allProductLineItems property of the basket with the method getProductLineItems().
相关推荐
### IMSL库函数详解 #### 引言:深入探索IMSL Fortran Numerical Library IMSL库函数,作为一款在科学计算与工程分析领域享有盛誉的数学库,提供了广泛而深入的数值算法集合,旨在解决复杂的数学问题。...
ISML6.0 licenseISML6.0 license IMSL(R) IMSL Fortran Numerical Library, Version 6.0.0 This document contains release notes for IMSL Fortran Numerical Library, Version 6.0.0 for Microsoft Window ...
VS Code的Isml Linter扩展 Isml Linter的VS Code扩展。 您还可以直接通过npm安装linter,并利用其完整项目的lint功能,例如在构建过程中使用它。 此处提供更多信息: : 。 您还可以在此处找到可应用于此扩展程序的一...
最终的高性能HTTP I / O起源于Chtholly Nota Seniorious,而ISML起源于 。 在具有2×8G 3200MHz内存的单个4GHz Ryzen 3600内核上,在<0.7秒内发出100k(十万)HTTP请求。 Python 3.6√ Python 3.7√(建议使用...
《Fortran Library 6.0 Function Catalog》是针对ISML(IMSL Fortran Numerical Library)的详尽功能目录,该目录系统地列出了库中包含的所有数学与统计功能,旨在为用户提供一个全面的资源指南,帮助他们了解并利用...
在例子中提到的是ISML6.0版本的下载链接,但请注意,实际下载时应根据需求和系统环境选择合适的版本。下载完成后,需要进行安装,并在安装过程中输入有效的序列号,如例子中的201111。除了序列号,还必须拥有一个...
isml和ds文件的语法高亮 验证isml文件(基于htmlhint插件,可通过.htmlhintrc配置) 对ISML语法的高级支持 悬停信息 自动完成标记 自动格式化 查找符号 突出显示所选标签 重命名标签(通过F2) 设置断点 踏步 更改...
功能:*使用dwMarker HTML注释*在元素面板中添加新的SFCC侧面板*在VS Code / Eclipse中打开ISML,管道和控制器*在Business Manager中打开内容插槽和资产*支持明暗主题免责声明:商标和产品名称Salesforce:registered...
它支持 ism/isml 和 csm 清单以及 VC-1、H.264、WMAv2、WmaPro 和 AAC 编解码器。 它使用 mplayer 播放流,它是用 php 编写的。 我为 Windows 和 Linux 提供了预配置版本的 smthplayer(即使不能保证 Windows 支持...