Wrap a selected phrase with external content


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


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 BLUEPHRASE 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 BLUEPROCESSOR 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
div {
img `section-logo.jpg` ^float:right

And here is the output created by the builder:

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

<img src='section-logo.jpg' style='float:right' />
<section class=stdLogo>
<p>Origins and legacy of the Gregorian calendar</p>
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 {
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.
!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`


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

syntax > pragmas > enclosureWrap a selected phrase with external content

🔗 🔎