X

Declare variables on-the-fly and use them anywhere

Substituting

Declaring and using variables in your BLUEPHRASE templates gives them the flexibility to be used over and over.

Use of the include and enclosure pragmas are two important techniques to organize your body of work. Both allow you to inject standard templates into your manuscript, providing branding and cohesion when used consistently.

Substitution variables allow you to apply different textual content to within these standard templates.

Variable notation uses the dollar-sign symbol $, like this:

$DESCRIPTION="Give me a day, with the sun on my shoulders, with a breeze on my face, with the earth between my toes, and I will thank you forever."
$KEYWORDS="joy,shoulders,face,toes"
$TITLE="Give Me a Day with Joy"

When these variables are declared, they can be used elsewhere in your writing. Consider this enclosure template ...

html {
head {
meta *charset=UTF-8
meta *name=viewport *content='width=device-width, initial-scale=1'
meta *name=description *content='$DESCRIPTION'
meta *name=keywords *content='$KEYWORDS'
title $TITLE
}
body {
!target-matter
}
}
std-template.blue

... and this web page ...

!enclosure #poem `./std-template.blue`

$DESCRIPTION="Give me a day with joy, and I will thank you forever."
$KEYWORDS="joy, shoulders, face, toes"
$TITLE="Give Me a Day with Joy"

article#poem {
Give me a day,
with the sun on my shoulders,
with a breeze on my face,
with the earth between my toes,
and I will thank you forever.
}
give-me-a-day-with-joy.blue

The substitution variables are applied to the enclosure template resulting in a final HTML document like this:

<html>
<head>
<meta charset=UTF-8 />
<meta name=viewport content='width=device-width, initial-scale=1' />
<meta name=description content='Give me a day with joy, and I will thank you forever.' />
<meta name=keywords content='joy, shoulders, face, toes' />
<title>Give Me a Day with Joy</title>
</head>
<body>
<article id=poem>
<p>Give me a day,</p>
<p>with the sun on my shoulders,</p>
<p>with a breeze on my face,</p>
<p>with the earth between my toes,</p>
<p>and I will thank you forever.</p>
</article>
</body>
</html>
give-me-a-day-with-joy.html

Declare variables on-the-fly and use them anywhere

🔗 🔎