Skip to content

fentech/freemarker-magnolia-snippets

Repository files navigation

Magnolia-Freemarker Snippets

Visual Studio snippets for the FreeMarker templating language. The snippets work in .ftl files.

Demo

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:
    1. children
    2. contentByPath
    3. contentById
    4. contentListByTemplateId
    5. page
    6. link
    7. externalLink
    8. externalLinkTitle
    9. linkPrefix
    10. localizedLinks
    11. asContentMap
    12. asJCRNode
    13. asNodeList
    14. ancestors
    15. parent
    16. root
    17. siteRoot
    18. dump
    19. isEditMode
    20. isPreviewMode
    21. isAuthorInstance
    22. isPublicInstance
    23. decode
    24. abbreviateString
    25. queryStringAndFragment
    26. language
    27. wrapForI18n
    28. isCurrentLocale
    29. metaData
    30. fileExtension
    31. 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.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published