Wrap a selected phrase with external content

enclosure

The "enclosure" pragma is used to wrap a phrase and all its subordinates with the contents of an external manuscript.

Syntax

The syntax for the enclosure pragma consists of:

  • An exclamation point !
  • The keyword enclosure
  • A selector specified as a semantax, identifier or classname
  • A sourceref containing the name of the external manuscript to target.

The external manuscript must be in BLUE-PHRASE format. Also, there must be a --target-matter pragma somewhere within it.

!enclosure .selector `target`           // classname selector
!enclosure #selector `target` // identifier selector
!enclosure *semantax=selector `target` // semantax selector
enclosure pragma syntax

The target may be an absolute path specifying the target from the file system's root, or a relative path, specifying the target using dot notation (.\filename.blue) or dot-dot notation (..\other-dir\filename.blue).

The enclosing process

Enclosure pragmas should be defined at the beginning of manuscripts.

During manuscript compilation, the BLUE-PROCESSOR will attempt to match each phrase against the enclosure's selector, matching the phrase's semantax, identifier, and classname against the enclosure's selector. When a match occurs, the enclosing process is triggered.

Example 1

!enclosure .stdLogo `file2.blue`

section .stdLogo {
h1 Clocks
p From hourglasses to atomic clocks
}

section .stdLogo {
h1 Calendars
p Origins and legacy of the Gregorian calendar
}
file1.blue
div {
img `section-logo.jpg` ^float:right
!target-matter
}
file2.blue

And here is the output created by the builder:

<div>
<img src='section-logo.jpg' style='float:right' />
<section class=stdLogo>
<h1>Clocks</h1>
<p>From hourglasses to atomic clocks</p>
</section>
</div>

<div>
<img src='section-logo.jpg' style='float:right' />
<section class=stdLogo>
<h1>Calendars</h1>
<p>Origins and legacy of the Gregorian calendar</p>
</section>
</div>
Compiled output

Example 2

The enclosure process is the recommended way to build a document template for a website. To do this, write each page's content inside a main or article containing phrase. Make that containing phrase the enclosure's target selector. Delegate all of the website's boilerplate stuff, such as html, head, link and script elements, to the enclosure target.

!blue 2.0
$TITLE="Predicting Weather"
!enclosure *semantax=main `file4.blue`

main {
h1 $TITLE
p Surface temperature differences in turn cause pressure
differences. Higher altitudes are cooler than lower altitudes,
as most atmospheric heating is due to contact with the Earth's
surface while radiative losses to space are mostly constant.
p Weather forecasting is the application of science and
technology to predict the state of the atmosphere for a
future time and a given location. The Earth's weather system
is a chaotic system; as a result, small changes to one part
of the system can grow to have large effects on the system as
a whole.
p Human attempts to control the weather have occurred throughout
history, and there is evidence that human activities such as
agriculture and industry have modified weather patterns.
}
file3.blue
!blue 2.0            
html {
head {
meta *charset=UTF-8
meta *name=viewport *content='width=device-width, initial-scale=1'
link `/css/std-styles.css` *rel=stylesheet *type=text/css
title $TITLE
}
body {
!include `header.blue`

!target-matter

!include `footer.blue`
}
script `/js/std-script.js`
}
file4.blue

syntax > pragmas > enclosureWrap a selected phrase with external content

Q