Code Modules — Docs
Indenting
Indenting
Use of #INDENT# Variable
I like my source code to be properly indented; it makes it easier to read. The #INDENT# variable, whose value is just white space set by the calling module, allows this.
While it isn’t shown in the examples in this documentation, each line of markup that is returned from the module can be preceded with the #INDENT# variable. The variable will be replaced with the white space value when the markup is returned. The call to the module can contain an #INDENT# variable defining that white space value; if none is set, a default value is defined in the Pages module entry file and is used instead.
An example of a piece of markup with #INDENT# is:
1#INDENT#<p>2#INDENT# Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.3#INDENT#</p>
An example of a call to a module with #INDENT# defined as three tabs is:
<!-- #bbinclude "/markup/blog/entry.shtml"#bbincludeoptions#="inline=true"#TEMPLATE# = 'teasers-with-images'#INDENT# = ' '--><!-- end bbinclude -->
Where to Define #INDENT# Value?
I always define a global #INDENT# variable in the Pages module entry file with a default value, usually two tabs. It can then be overridden in each calling file on a per module basis as needed. Don’t define the #INDENT# value within a module itself because then the value can’t be easily overriden by the calling file; sometimes markup output from a module requires different levels of indent depending on where it is being used.
Tabs vs. Spaces
Without wading into the great tabs versus spaces debate, I prefer using tabs for this purpose. But it doesn’t matter: either is fine.
If you don’t care about indenting, the #INDENT# variable can be omitted entirely.
BBEdit Feature Suggestion
If I was designing BBEdit’s persistent include syntax, I’d add a feature to allow the returned markup to be indented by the calling file. However, the #INDENT# variable approach does work at the cost of making the markup more difficult to read within the module. When working on the markup, I often first strip the #INDENT# string off the front of each line and then add it back after I’m done.
Indenting Omitted from Rest of This Documentation
In the rest of the documentation, I omit #INDENT# calls and usage to help eliminate clutter. But they are present in the source code for the Sample Website and Modules.