Merge pull request #2847 from blutorange/lang-freemarker
Implements #2383 Add syntax modes for FreeMarker template languagepull/2894/head
commit
93c7165c32
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,111 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { registerLanguage } from '../_.contribution';
|
||||
|
||||
declare var AMD: any;
|
||||
declare var require: any;
|
||||
|
||||
// freemarker.tag-square.interpolation-dollar is the default
|
||||
// According the docs tag-auto will be the default for version 2.4+, but that
|
||||
// hasn't event been released yet.
|
||||
registerLanguage({
|
||||
id: 'freemarker2',
|
||||
extensions: ['.ftl', '.ftlh', '.ftlx'],
|
||||
aliases: ['FreeMarker2', 'Apache FreeMarker2'],
|
||||
loader: () => {
|
||||
if (AMD) {
|
||||
return new Promise<typeof import('./freemarker2')>((resolve, reject) => {
|
||||
require(['vs/basic-languages/freemarker2/freemarker2'], resolve, reject);
|
||||
}).then((m) => m.TagAngleInterpolationDollar);
|
||||
} else {
|
||||
return import('./freemarker2').then((m) => m.TagAutoInterpolationDollar);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
registerLanguage({
|
||||
id: 'freemarker2.tag-angle.interpolation-dollar',
|
||||
aliases: ['FreeMarker2 (Angle/Dollar)', 'Apache FreeMarker2 (Angle/Dollar)'],
|
||||
loader: () => {
|
||||
if (AMD) {
|
||||
return new Promise<typeof import('./freemarker2')>((resolve, reject) => {
|
||||
require(['vs/basic-languages/freemarker2/freemarker2'], resolve, reject);
|
||||
}).then((m) => m.TagAngleInterpolationDollar);
|
||||
} else {
|
||||
return import('./freemarker2').then((m) => m.TagAngleInterpolationDollar);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
registerLanguage({
|
||||
id: 'freemarker2.tag-bracket.interpolation-dollar',
|
||||
aliases: ['FreeMarker2 (Bracket/Dollar)', 'Apache FreeMarker2 (Bracket/Dollar)'],
|
||||
loader: () => {
|
||||
if (AMD) {
|
||||
return new Promise<typeof import('./freemarker2')>((resolve, reject) => {
|
||||
require(['vs/basic-languages/freemarker2/freemarker2'], resolve, reject);
|
||||
}).then((m) => m.TagBracketInterpolationDollar);
|
||||
} else {
|
||||
return import('./freemarker2').then((m) => m.TagBracketInterpolationDollar);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
registerLanguage({
|
||||
id: 'freemarker2.tag-angle.interpolation-bracket',
|
||||
aliases: ['FreeMarker2 (Angle/Bracket)', 'Apache FreeMarker2 (Angle/Bracket)'],
|
||||
loader: () => {
|
||||
if (AMD) {
|
||||
return new Promise<typeof import('./freemarker2')>((resolve, reject) => {
|
||||
require(['vs/basic-languages/freemarker2/freemarker2'], resolve, reject);
|
||||
}).then((m) => m.TagAngleInterpolationBracket);
|
||||
} else {
|
||||
return import('./freemarker2').then((m) => m.TagAngleInterpolationBracket);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
registerLanguage({
|
||||
id: 'freemarker2.tag-bracket.interpolation-bracket',
|
||||
aliases: ['FreeMarker2 (Bracket/Bracket)', 'Apache FreeMarker2 (Bracket/Bracket)'],
|
||||
loader: () => {
|
||||
if (AMD) {
|
||||
return new Promise<typeof import('./freemarker2')>((resolve, reject) => {
|
||||
require(['vs/basic-languages/freemarker2/freemarker2'], resolve, reject);
|
||||
}).then((m) => m.TagBracketInterpolationBracket);
|
||||
} else {
|
||||
return import('./freemarker2').then((m) => m.TagBracketInterpolationBracket);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
registerLanguage({
|
||||
id: 'freemarker2.tag-auto.interpolation-dollar',
|
||||
aliases: ['FreeMarker2 (Auto/Dollar)', 'Apache FreeMarker2 (Auto/Dollar)'],
|
||||
loader: () => {
|
||||
if (AMD) {
|
||||
return new Promise<typeof import('./freemarker2')>((resolve, reject) => {
|
||||
require(['vs/basic-languages/freemarker2/freemarker2'], resolve, reject);
|
||||
}).then((m) => m.TagAutoInterpolationDollar);
|
||||
} else {
|
||||
return import('./freemarker2').then((m) => m.TagAutoInterpolationDollar);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
registerLanguage({
|
||||
id: 'freemarker2.tag-auto.interpolation-bracket',
|
||||
aliases: ['FreeMarker2 (Auto/Bracket)', 'Apache FreeMarker2 (Auto/Bracket)'],
|
||||
loader: () => {
|
||||
if (AMD) {
|
||||
return new Promise<typeof import('./freemarker2')>((resolve, reject) => {
|
||||
require(['vs/basic-languages/freemarker2/freemarker2'], resolve, reject);
|
||||
}).then((m) => m.TagAutoInterpolationBracket);
|
||||
} else {
|
||||
return import('./freemarker2').then((m) => m.TagAutoInterpolationBracket);
|
||||
}
|
||||
}
|
||||
});
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,61 @@
|
||||
<#ftl stripText=false>
|
||||
|
||||
<#-- Free marker demo -->
|
||||
|
||||
<#comment>
|
||||
This demonstrates the FreeMarker language. The default theme is not very
|
||||
colorful and displays many different token types in the same color, but keep in
|
||||
mind that you can define your own theme (or extend an existing one).
|
||||
|
||||
Note that free marker actually defines 6 similar but different syntax modes:
|
||||
|
||||
- 3 tag syntax modes: Angle (<#if>), Bracket ([#if]), and Auto.
|
||||
- 2 interpolation modes: Dollar (${...}) and Bracket ([=...])
|
||||
|
||||
In auto mode, the first tag determines the tag syntax. You can use the language
|
||||
IDs "freemarker.tag-bracket.interpolation-dollar" etc. to force a specific mode.
|
||||
|
||||
The default FreeMarker mode is Angle/Dollar.
|
||||
</#comment>
|
||||
|
||||
<#macro greet name>
|
||||
<font size="+2">Hello [=name]!</font>
|
||||
</#macro>
|
||||
|
||||
<#macro border>
|
||||
<table border=4 cellspacing=0 cellpadding=4><tr><td>
|
||||
<#nested>
|
||||
</tr></td></table>
|
||||
</#macro>
|
||||
|
||||
<#function avg x y>
|
||||
<#return (x + y) / 2>
|
||||
</#function>
|
||||
|
||||
<#assign user = "Juila Smith">
|
||||
<#assign animals = [{"name": "Tanuki", "price": 200}, {"name": "Phoenix", "price": 1111}]>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Welcome!</title>
|
||||
</head>
|
||||
<body>
|
||||
<#-- Greet the user with his/her name -->
|
||||
<h1>
|
||||
<@greet user />
|
||||
</h1>
|
||||
|
||||
<p>We have these animals:
|
||||
|
||||
<ul>
|
||||
<#list animals as animal>
|
||||
<li>[=animal.name] for [=animal.price] Euros
|
||||
</#list>
|
||||
</ul>
|
||||
|
||||
<@border>The bordered text</@border>
|
||||
|
||||
The average of 35 and 49 is [=avg(35, 49)].
|
||||
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,61 @@
|
||||
<#ftl stripText=false>
|
||||
|
||||
<#-- Free marker demo -->
|
||||
|
||||
<#comment>
|
||||
This demonstrates the FreeMarker language. The default theme is not very
|
||||
colorful and displays many different token types in the same color, but keep in
|
||||
mind that you can define your own theme (or extend an existing one).
|
||||
|
||||
Note that free marker actually defines 6 similar but different syntax modes:
|
||||
|
||||
- 3 tag syntax modes: Angle (<#if>), Bracket ([#if]), and Auto.
|
||||
- 2 interpolation modes: Dollar (${...}) and Bracket ([=...])
|
||||
|
||||
In auto mode, the first tag determines the tag syntax. You can use the language
|
||||
IDs "freemarker.tag-bracket.interpolation-dollar" etc. to force a specific mode.
|
||||
|
||||
The default FreeMarker mode is Angle/Dollar.
|
||||
</#comment>
|
||||
|
||||
<#macro greet name>
|
||||
<font size="+2">Hello ${name}!</font>
|
||||
</#macro>
|
||||
|
||||
<#macro border>
|
||||
<table border=4 cellspacing=0 cellpadding=4><tr><td>
|
||||
<#nested>
|
||||
</tr></td></table>
|
||||
</#macro>
|
||||
|
||||
<#function avg x y>
|
||||
<#return (x + y) / 2>
|
||||
</#function>
|
||||
|
||||
<#assign user = "Juila Smith">
|
||||
<#assign animals = [{"name": "Tanuki", "price": 200}, {"name": "Phoenix", "price": 1111}]>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Welcome!</title>
|
||||
</head>
|
||||
<body>
|
||||
<#-- Greet the user with his/her name -->
|
||||
<h1>
|
||||
<@greet user />
|
||||
</h1>
|
||||
|
||||
<p>We have these animals:
|
||||
|
||||
<ul>
|
||||
<#list animals as animal>
|
||||
<li>${animal.name} for ${animal.price} Euros
|
||||
</#list>
|
||||
</ul>
|
||||
|
||||
<@border>The bordered text</@border>
|
||||
|
||||
The average of 35 and 49 is ${avg(35, 49)}.
|
||||
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,65 @@
|
||||
Auto mode detect the tag syntax mode automatically.
|
||||
Try exchanging the order of the next two lines and see what happens!
|
||||
|
||||
[#ftl stripText=false]
|
||||
<#ftl stripText=false>
|
||||
|
||||
<#-- Free marker demo -->
|
||||
|
||||
<#comment>
|
||||
This demonstrates the FreeMarker language. The default theme is not very
|
||||
colorful and displays many different token types in the same color, but keep in
|
||||
mind that you can define your own theme (or extend an existing one).
|
||||
|
||||
Note that free marker actually defines 6 similar but different syntax modes:
|
||||
|
||||
- 3 tag syntax modes: Angle (<#if>), Bracket ([#if]), and Auto.
|
||||
- 2 interpolation modes: Dollar (${...}) and Bracket ([=...])
|
||||
|
||||
In auto mode, the first tag determines the tag syntax. You can use the language
|
||||
IDs "freemarker.tag-bracket.interpolation-dollar" etc. to force a specific mode.
|
||||
|
||||
The default FreeMarker mode is Angle/Dollar.
|
||||
</#comment>
|
||||
|
||||
<#macro greet name>
|
||||
<font size="+2">Hello [=name]!</font>
|
||||
</#macro>
|
||||
|
||||
<#macro border>
|
||||
<table border=4 cellspacing=0 cellpadding=4><tr><td>
|
||||
<#nested>
|
||||
</tr></td></table>
|
||||
</#macro>
|
||||
|
||||
<#function avg x y>
|
||||
<#return (x + y) / 2>
|
||||
</#function>
|
||||
|
||||
<#assign user = "Juila Smith">
|
||||
<#assign animals = [{"name": "Tanuki", "price": 200}, {"name": "Phoenix", "price": 1111}]>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Welcome!</title>
|
||||
</head>
|
||||
<body>
|
||||
<#-- Greet the user with his/her name -->
|
||||
<h1>
|
||||
<@greet user />
|
||||
</h1>
|
||||
|
||||
<p>We have these animals:
|
||||
|
||||
<ul>
|
||||
<#list animals as animal>
|
||||
<li>[=animal.name] for [=animal.price] Euros
|
||||
</#list>
|
||||
</ul>
|
||||
|
||||
<@border>The bordered text</@border>
|
||||
|
||||
The average of 35 and 49 is [=avg(35, 49)].
|
||||
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,65 @@
|
||||
Auto mode detect the tag syntax mode automatically.
|
||||
Try exchanging the order of the next two lines and see what happens!
|
||||
|
||||
<#ftl stripText=false>
|
||||
[#ftl stripText=false]
|
||||
|
||||
<#-- Free marker demo -->
|
||||
|
||||
<#comment>
|
||||
This demonstrates the FreeMarker language. The default theme is not very
|
||||
colorful and displays many different token types in the same color, but keep in
|
||||
mind that you can define your own theme (or extend an existing one).
|
||||
|
||||
Note that free marker actually defines 6 similar but different syntax modes:
|
||||
|
||||
- 3 tag syntax modes: Angle (<#if>), Bracket ([#if]), and Auto.
|
||||
- 2 interpolation modes: Dollar (${...}) and Bracket ([=...])
|
||||
|
||||
In auto mode, the first tag determines the tag syntax. You can use the language
|
||||
IDs "freemarker.tag-bracket.interpolation-dollar" etc. to force a specific mode.
|
||||
|
||||
The default FreeMarker mode is Angle/Dollar.
|
||||
</#comment>
|
||||
|
||||
<#macro greet name>
|
||||
<font size="+2">Hello ${name}!</font>
|
||||
</#macro>
|
||||
|
||||
<#macro border>
|
||||
<table border=4 cellspacing=0 cellpadding=4><tr><td>
|
||||
<#nested>
|
||||
</tr></td></table>
|
||||
</#macro>
|
||||
|
||||
<#function avg x y>
|
||||
<#return (x + y) / 2>
|
||||
</#function>
|
||||
|
||||
<#assign user = "Juila Smith">
|
||||
<#assign animals = [{"name": "Tanuki", "price": 200}, {"name": "Phoenix", "price": 1111}]>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Welcome!</title>
|
||||
</head>
|
||||
<body>
|
||||
<#-- Greet the user with his/her name -->
|
||||
<h1>
|
||||
<@greet user />
|
||||
</h1>
|
||||
|
||||
<p>We have these animals:
|
||||
|
||||
<ul>
|
||||
<#list animals as animal>
|
||||
<li>${animal.name} for ${animal.price} Euros
|
||||
</#list>
|
||||
</ul>
|
||||
|
||||
<@border>The bordered text</@border>
|
||||
|
||||
The average of 35 and 49 is ${avg(35, 49)}.
|
||||
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,61 @@
|
||||
[#ftl stripText=false]
|
||||
|
||||
[#-- Free marker demo --]
|
||||
|
||||
[#comment]
|
||||
This demonstrates the FreeMarker language. The default theme is not very
|
||||
colorful and displays many different token types in the same color, but keep in
|
||||
mind that you can define your own theme (or extend an existing one).
|
||||
|
||||
Note that free marker actually defines 6 similar but different syntax modes:
|
||||
|
||||
- 3 tag syntax modes: Angle (<#if>), Bracket ([#if]), and Auto.
|
||||
- 2 interpolation modes: Dollar (${...}) and Bracket ([=...])
|
||||
|
||||
In auto mode, the first tag determines the tag syntax. You can use the language
|
||||
IDs "freemarker.tag-bracket.interpolation-dollar" etc. to force a specific mode.
|
||||
|
||||
The default FreeMarker mode is Angle/Dollar.
|
||||
[/#comment]
|
||||
|
||||
[#macro greet name]
|
||||
<font size="+2">Hello [=name]!</font>
|
||||
[/#macro[
|
||||
|
||||
[#macro border]
|
||||
<table border=4 cellspacing=0 cellpadding=4><tr><td>
|
||||
[#nested]
|
||||
</tr></td></table>
|
||||
[/#macro]
|
||||
|
||||
[#function avg x y]
|
||||
[#return (x + y) / 2]
|
||||
[/#function]
|
||||
|
||||
[#assign user = "Juila Smith"]
|
||||
[#assign animals = [{"name": "Tanuki", "price": 200}, {"name": "Phoenix", "price": 1111}]]
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Welcome!</title>
|
||||
</head>
|
||||
<body>
|
||||
[#-- Greet the user with his/her name --]
|
||||
<h1>
|
||||
<@greet user />
|
||||
</h1>
|
||||
|
||||
<p>We have these animals:
|
||||
|
||||
<ul>
|
||||
[#list animals as animal]
|
||||
<li>[=animal.name] for [=animal.price] Euros
|
||||
[/#list][
|
||||
</ul>
|
||||
|
||||
<@border>The bordered text</@border>
|
||||
|
||||
The average of 35 and 49 is [=avg(35, 49]}.
|
||||
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,61 @@
|
||||
[#ftl stripText=false]
|
||||
|
||||
[#-- Free marker demo --]
|
||||
|
||||
[#comment]
|
||||
This demonstrates the FreeMarker language. The default theme is not very
|
||||
colorful and displays many different token types in the same color, but keep in
|
||||
mind that you can define your own theme (or extend an existing one).
|
||||
|
||||
Note that free marker actually defines 6 similar but different syntax modes:
|
||||
|
||||
- 3 tag syntax modes: Angle (<#if>), Bracket ([#if]), and Auto.
|
||||
- 2 interpolation modes: Dollar (${...}) and Bracket ([=...])
|
||||
|
||||
In auto mode, the first tag determines the tag syntax. You can use the language
|
||||
IDs "freemarker.tag-bracket.interpolation-dollar" etc. to force a specific mode.
|
||||
|
||||
The default FreeMarker mode is Angle/Dollar.
|
||||
[/#comment]
|
||||
|
||||
[#macro greet name]
|
||||
<font size="+2">Hello ${name}!</font>
|
||||
[/#macro[
|
||||
|
||||
[#macro border]
|
||||
<table border=4 cellspacing=0 cellpadding=4><tr><td>
|
||||
[#nested]
|
||||
</tr></td></table>
|
||||
[/#macro]
|
||||
|
||||
[#function avg x y]
|
||||
[#return (x + y) / 2]
|
||||
[/#function]
|
||||
|
||||
[#assign user = "Juila Smith"]
|
||||
[#assign animals = [{"name": "Tanuki", "price": 200}, {"name": "Phoenix", "price": 1111}]]
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Welcome!</title>
|
||||
</head>
|
||||
<body>
|
||||
[#-- Greet the user with his/her name --]
|
||||
<h1>
|
||||
<@greet user />
|
||||
</h1>
|
||||
|
||||
<p>We have these animals:
|
||||
|
||||
<ul>
|
||||
[#list animals as animal]
|
||||
<li>${animal.name} for ${animal.price} Euros
|
||||
[/#list][
|
||||
</ul>
|
||||
|
||||
<@border>The bordered text</@border>
|
||||
|
||||
The average of 35 and 49 is ${avg(35, 49)}.
|
||||
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,61 @@
|
||||
<#ftl stripText=false>
|
||||
|
||||
<#-- Free marker demo -->
|
||||
|
||||
<#comment>
|
||||
This demonstrates the FreeMarker language. The default theme is not very
|
||||
colorful and displays many different token types in the same color, but keep in
|
||||
mind that you can define your own theme (or extend an existing one).
|
||||
|
||||
Note that free marker actually defines 6 similar but different syntax modes:
|
||||
|
||||
- 3 tag syntax modes: Angle (<#if>), Bracket ([#if]), and Auto.
|
||||
- 2 interpolation modes: Dollar (${...}) and Bracket ([=...])
|
||||
|
||||
In auto mode, the first tag determines the tag syntax. You can use the language
|
||||
IDs "freemarker.tag-bracket.interpolation-dollar" etc. to force a specific mode.
|
||||
|
||||
The default FreeMarker mode is Angle/Dollar.
|
||||
</#comment>
|
||||
|
||||
<#macro greet name>
|
||||
<font size="+2">Hello ${name}!</font>
|
||||
</#macro>
|
||||
|
||||
<#macro border>
|
||||
<table border=4 cellspacing=0 cellpadding=4><tr><td>
|
||||
<#nested>
|
||||
</tr></td></table>
|
||||
</#macro>
|
||||
|
||||
<#function avg x y>
|
||||
<#return (x + y) / 2>
|
||||
</#function>
|
||||
|
||||
<#assign user = "Juila Smith">
|
||||
<#assign animals = [{"name": "Tanuki", "price": 200}, {"name": "Phoenix", "price": 1111}]>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Welcome!</title>
|
||||
</head>
|
||||
<body>
|
||||
<#-- Greet the user with his/her name -->
|
||||
<h1>
|
||||
<@greet user />
|
||||
</h1>
|
||||
|
||||
<p>We have these animals:
|
||||
|
||||
<ul>
|
||||
<#list animals as animal>
|
||||
<li>${animal.name} for ${animal.price} Euros
|
||||
</#list>
|
||||
</ul>
|
||||
|
||||
<@border>The bordered text</@border>
|
||||
|
||||
The average of 35 and 49 is ${avg(35, 49)}.
|
||||
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue