Commonplace comes with a few libraries built-in. They can all be imported by name.
jQuery 2.0.2
This is a version of jQuery that runs at version 2.0.2. It was custom-compiled with the following grunt parameters:
-sizzle,-wrap,-event-alias,-ajax,-ajax/script,-ajax/jsonp,-ajax/xhr,-effects,-offset,-deprecated
Customizations:
- The jQuery AMD support was modified to define a name as the first argument to
define()
. - The custom parameters eliminate many standard jQuery components. Some jQuery plugins may not function, especially those that depend on Sizzle selectors and the jQuery AJAX functions.
Underscore 1.4.4
This is a vanilla installation of Underscore 1.4.4, with one exception. A define()
call was added to make it loadable in an AMD context.
format.js
This is a small library written by @potch. It has only been modified to add AMD support.
require.js
This is a version of require.js, pinned at version 2.1.4.
As outlined in the AMD documentation, the implementation of require.js has been modified slightly from its original form. These modifications include:
<script>
tags that are injected are placed at the end of the body rather than in the<head>
.- Rather than using the
async
attribute, the scripts are given adefer
attribute. This is done to more closely mimic therequire()
process ofamd.js
.
In general, these customizations do not change the functionality of require.js, and are probably safe to revert. This may, however, produce unexpected changes between local development and production environments.
Nunjucks
The version of Nunjucks that is included is a highly customized runtime. It is based on 1.0, though the version in Commonplace is largely incompatible with the nunjucks-slim
implementation that is available from the vanilla Nunjucks repo.
Some of the modifications include:
- Various stubs have been removed. This includes references to the parser, compiler, and tokenizer.
- Web loader code has been removed. This code allowed templates to be loaded remotely, though this isn't necessary with AMD modules.
- Errors are not wrapped as template errors.
- Most
Template
logic has been nooped because Commonplace deals exclusively with compiled templates. - The template compiler is patched to prevent certain types of code from being generated, and the corresponding runtime functions have been removed to save space.
nunjucks.compat.js
This is a library that patches the Nunjucks runtime to allow Python members and variables to be used from within compiled Nunjucks templates.