Introduction to Bear

Welcome to the Bear CMS docs. This page is a basic documentation effort by way of example. The source file is available at staging/index.text.


  1. Copy bear to wherever you want it to reside.

  2. optional: Install Text::Markdown from CPAN. If you don't know how to install CPAN modules then you probably want to ask someone who does (it's not hard, but it's quirky and if you didn't know already then you probably have better things to do with your time).


You set up bear by putting files in a directory structure like this:



You run bear like this:

    bear $DOCROOT destination-path


When you run the program it sweeps the staging area looking for files to do something with, and then attempts to render or copy those files so that the $DOCROOT mirrors the structure of the staging area but in rendered form. In general it only does things if the file in the staging area is newer than the file in $DOCROOT, or if the equivalent file does not exist in $DOCROOT.

Rendering is the process of turning a raw (or somewhat marked up) text file and turning it into an HTML page.


A directory can have a %prefs.txt file, which specifies preferences applying to that directory and all subdirectories that don't override. Each preference is inherited by all subdirectories that do not override the preference. Each line in the preference file is a directive with a name value pair:

    #name value

Only the first space is relevant, so you can do things like

    #footer This is a global footer.

You can define your own preferences -- just stored text to use in your web pages -- but there are two (currently) special preferences that bear relies on:

BEAR_template_inherits -- tells bear to shove the output of this directory's template into the next higher level template:

    %BEAR_template_inherits true

BEAR_use_markdown -- tells bear to render this directory's files using the Markdown syntax

    %BEAR_use_markdown true

Other special preferences may be defined in the future, using the BEAR_ prefix.

File Specific Preferences

Text files to be rendered can set their own preference directives by starting the file with a block of directives in the same format as the general preference files use. In general, any preference can be set or overridden, but setting or overriding directives affecting how bear renders (e.g. BEAR_template_inherits) is not supported (they may work, but may have perverse effects).


%template.txt files should be formatted using normal HTML or XHTML, unless they inherit, in which case they should be the relevant fragment of HTML/XHTML.

Templates have two special tags that bear uses to render contained text:

The bodytext tag is replaced by the source file's text, or the rendered output of a template which inherits from this one.


The transform tag will eventually support a number of special text transformations, but currently is a one-time hack to get Faisal's Quotes File to work.

Templates cannot declare their own preference directives.


If you declare a destination path then the contents of $DOCROOT are synchronized to the destination location by rsync (via SSH if to a remote site).

Note: that the staging area is published to the server along with the rendered output. This is intentional. You may wish to put a .htaccess file in there.