Magnolia-Freemarker Snippets
Visual Studio snippets for the FreeMarker templating language. The snippets work in .ftl
files.
Install the Extension →
Jump to...
Freemarker Snippets
HTML Snippets
Magnolia Snippets
Note: All output examples below have dummy data, in curly bracket (i.e. {variableName}
), that represent tab stops, to show you how it should display.
Freemarker Snippets
All ftl commands have a arrow wrapper option <>
with a similar prefix.
include
[#include "{/path/to/include}"]
macro:call
[@{macroName} {argument=argumentValue} /]
macro:define
[#macro {macroName} {arguments=withDefaultValue}]
{code}
[/#macro]
if
[#if {statement}]
{code}
[/#if]
if:has
[#if {statement}?has_content]
{code}
[/#if]
if:else
[#if {statement}]
{code}
[#else]
{code}
[/#if]
if:elseif
[#if {statement}]
{code}
[#elseif {statement2}]
{code}
[/#if]
else
[#else]
elseif
[#elseif {statement}]
switch
[#switch {variable}]
[#case {value1}]
{code}
[#break]
[/#switch]
case
[#case {value}]
break
[#break]
tag
[#{tagName}]
/
[/#{tagName}]
int
${$0}
assign
[#assign {nameOfVariable = value}]
local
[#local {nameOfVariable = value}]
HTML Snippets
Add a period ".
" to the end of any html snippet to add a class property (e.g. "section.
" outputs <section class=""></section>
).
Snippet |
Has Class |
Output |
section |
✔ |
<section></section> |
header |
✔ |
<header></header> |
main |
✔ |
<main></main> |
div |
✔ |
<div></div> |
form |
✔ |
<form id="{id}" action="{action}" method="{method}"></form> |
input |
✔ |
<input id="{name}" name="{name}" type="{type}" value="{value}" /> |
span |
✔ |
<span></span> |
h1 |
✔ |
<h1></h1> |
h2 |
✔ |
<h2></h2> |
h3 |
✔ |
<h3></h3> |
h4 |
✔ |
<h4></h4> |
p |
✔ |
<p></p> |
strong |
✔ |
<strong></strong> |
a |
✔ |
<a href="{href}"></a> |
button |
✔ |
<button></button> |
img |
✔ |
<img src="{src}" alt="{alt}" title="{title}"> |
meta |
|
<meta property="{property}" content="{content}"> |
link |
|
<link rel="{rel}" href="{href}"> |
script |
|
<script type="{type}" src="{src}"></script> |
script# |
|
<script id="{id}" type="{type}" src="{src}"></script> |
script:block |
|
<script></script> |
class |
|
class="" |
href |
|
href="" |
style |
|
style="" |
role |
|
role="" |
alt |
|
alt="" |
title |
|
title="" |
src |
|
src="" |
Magnolia Snippets
cmsfn
cmsfn.{option}()
- options:
- children
- contentByPath
- contentById
- contentListByTemplateId
- page
- link
- externalLink
- externalLinkTitle
- linkPrefix
- localizedLinks
- asContentMap
- asJCRNode
- asNodeList
- ancestors
- parent
- root
- siteRoot
- dump
- isEditMode
- isPreviewMode
- isAuthorInstance
- isPublicInstance
- decode
- abbreviateString
- queryStringAndFragment
- language
- wrapForI18n
- isCurrentLocale
- metaData
- fileExtension
- readableFileSize
dump
Outputs Magnolia cmsfn.dump()
templating function.
${cmsfn.dump({object_to_dump}, 3 , true)}
components
[#list components as component]
[@cms.component content=component /]
[/#list]
area
[@cms.area name="{areaName}" /]
Release Notes
v1.4.0
Adds arrow wrapper <>
option snippets for all ftl commands
v1.3.0
Adds form
and input
tag snippets
v1.2.0
Adds button
tag snippets
v1.1.5
Sets default depth
and asHtml
arguments of cmsfn.dump()
snippet.
v1.1.4
Adds snippets for the following HTML tags: span, a tag with class, image tag with class, meta, link, script (script, script with id, and script block). Updates the README to indicate which html tags have a 'with class' variant.
v1.1.3
Updates README
v1.1.2
Updates README with better documentation and adds demo.
v1.1.1
Fixes switch statement last tab stop.
v1.1.0
Adds the switch, case, break, and elseif snippets.