Package couchdbkit :: Package designer :: Module macros
[hide private]
[frames] | no frames]

Module macros

source code

Macros used by loaders. compatible with couchapp. It allow you to include code,
design docs members inside your views, shows and lists.

for example to include a code, add just after first function the line :
    // !code relativepath/to/some/code.js
To include a member of design doc and use it as a simple javascript object :

    // !json
All in one, example of a view :

    function(doc) {
        !code _attachments/js/md5.js
        if (doc.type == "user") {
            doc.gravatar = hex_md5(;
            emit(doc.username, doc)

This example includes md5.js code and uses md5 function to create gravatar hash
in your views.  So you could just store raw data in your docs and calculate
hash when views are updated.

Functions [hide private]
package_shows(doc, funcs, app_dir, objs) source code
package_views(doc, views, app_dir, objs) source code
apply_lib(doc, funcs, app_dir, objs) source code
run_code_macros(f_string, app_dir) source code
run_json_macros(doc, f_string, app_dir) source code
Variables [hide private]
  logger = logging.getLogger(__name__)
  __package__ = 'couchdbkit.designer'