Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

grunt-doctrine

mattimatti98MIT0.0.41

Grunt plugin to convert doctrine xml annotations into backbone models and collections. Useful in conjunction with doctrine apigility. Includes option to scaffold an entire BBB application

gruntplugin, doctrine, apigility, backbone, scaffold

readme

grunt-doctrine

Grunt plugin to convert doctrine xml annotations into backbone models and collections. useful in conjunction with doctrine apigility. Includes option to scaffold a complete BBB crud application.

Getting Started

This plugin requires Grunt.

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-doctrine --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-doctrine');

The "doctrine" task

Overview

In your project's Gruntfile, add a section named doctrine to the data object passed into grunt.initConfig().

grunt.initConfig({
  doctrine: {
    options: {
      // Task-specific options go here.
    },
    your_target: {
      // Target-specific file lists and/or options go here.
    },
  },
})

Options

options.appName

Type: String Default value: 'app'

The application name that will be written to the package.json file

options.root

Type: String Default value: '/'

The destination folder where the code will be generated.

options.endpoint

Type: String Default value: 'null'

The api endpoint for example http://example.com/v1/

options.backbone

Type: Object Default value: '{}'

Options for the backbone modules to use. Options will be described later in this module.

options.backbone.relational

Type: Boolean Default value: 'false'

Use Backbone.Relational

options.backbone.fetchcache

Type: Boolean Default value: 'false'

Use Backbone.Fetch cache plugin to cache resources?

options.backbone.modelDefaults

Type: Boolean Default value: 'false'

Declare defaults in Backbone models.

options.backbone.pushState

Type: Boolean Default value: 'false'

Enables pushState for Backbone.History

Usage Examples

Default Options

In this example, We create a complete module application

grunt.initConfig({
  doctrine: {
    options: {
          appName: 'app',
          root: 'tmp',
          endpoint: 'http://example.com/v1/'
        },
    src: ['test/fixtures/**/*.xml']
  },
})

Custom Options

in this example, we create a bbb modular application

grunt.initConfig({
  doctrine: {
    options: {
          appName: 'app',
          root: 'tmp',
          endpoint: 'http://example.com/v1/'
        },
    src: ['test/fixtures/**/*.xml']
  },
})

Contributing

Actually contributing is not permitted.

Release History

(Nothing yet)

License

Copyright (c) 2014 mattimatti. Licensed under the MIT license.

changelog

Changelog

  • v1.4.0: Change - Return a full Deferred object to allow request cancellation. Thanks to @garrensmith.
  • v1.3.0: Feature - Allow a prefix to be added to cache keys via Backbone.fetchCache.getLocalStorageKey function. Thanks to @zhulduz.
  • v1.2.1: Bugfix - Allow for URL function in clearItem method. Thanks to @prdn.
  • v1.2.0: Change - Call Model#parse when setting data on the model. Thanks to @charlietilt. Bugfix - fix cache expiration issue when the url is passed via options for the model. Thanks to @guilherme.
  • v1.1.2: Bugfix - Collection fetch now triggers both the collection's parse method, and the model's parse method - thanks to @BananaNeil
  • v1.1.1: Bugfix - respect jQuery.ajax's async: true option and resolve from the cache synchronously if required - thanks to @matthewkremer
  • v1.1.0: Change - Don't rely on global jQuery. We now use Backbone.root.jQuery or an AMD defined jquery module - thanks to @brett-shwom
  • v1.0.2: Bugfix - adds better check for localStorage support - thanks to @jfmoy
  • v1.0.1: Bugfix - updates fetch success callback signature to match Backbone's - thanks to @ydaniv
  • v1.0.0: Perform all cache fulfilment asynchronously. Only the promise, not the full $.Deferred object is returned from fetch functions.

  • v0.1.11: Account for custom URLs to be passed in fetch method options - thanks to @dincho

  • v0.1.10: Add getCacheKey function to allow custom cache keys - thanks to @ebertti
  • v0.1.9: Fixes a bug where clearing a cache item didn't get persisted to localStorage - thanks to @mzafer
  • v0.1.8: Trigger sync and cachesync events - thanks to @victorquinn.
  • v0.1.7: Ensures that parse is called for collections - thanks to @fernandopg.
  • v0.1.6: Update to call the correct add and reset methods for collections - thanks to @mzafer.
  • v0.1.5: Attempt to clear cache keys on PUT/POST/DELETE
  • v0.1.4: Bug fix for older Webkits which throw an error trying to JSON.parse(null)
  • v0.1.3: Auto expiration of old cache items if locaStorage gets full - thanks to @inf0rmer.
  • v0.1.2: Add AMD support.
  • v0.1.1: Add prefetch option.