This package has been deprecated

Author message:

Renaming now possible in main library and plugins

@doars/doars-alias

2.0.0 • Public • Published

npm @latest version minzipped size


@doars/doars-alias

Plugin for creating aliases or renaming any context or directive.

Install

From NPM

Install the package from NPM, then import and enable the library in your build.

npm i @doars/doars @doars/doars-alias
// Import library.
import Doars from '@doars/doars'
import DoarsAlias from '@doars/doars-alias'

// Setup a library instance.
const doars = new Doars()

// Setup the plugin.
const doarsAlias = new DoarsAlias(doars /*, options */)

// Enable library.
doars.enable()

IIFE build from jsDelivr

Add the IIFE build to the page from for example the jsDelivr CDN and enable the library.

<!-- Import library. -->
<script src="https://cdn.jsdelivr.net/npm/@doars/doars@1/dst/doars.iife.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@doars/doars-alias@1/dst/doars-alias.iife.js"></script>
<script type="application/javascript">
  document.addEventListener('DOMContentLoaded', () => {
    // Setup a library instance.
    const doars = new window.Doars()

    // Setup the plugin.
    const doarsAlias = window.DoarsAlias(doars /*, options */)

    // Enable library.
    doars.enable()
  })
</script>

ESM and IIFE builds are also available via the jsDelivr CDN.

Examples

// Setup a library instance.
const doars = new Doars()

// Setup the plugin.
const doarsAlias = new DoarsAlias(doars, {
  aliasContexts: {
    component: "root",
  },
  renameContexts: {
    references: "refs",
  },
  aliasDirective: {
    attribute: "attr",
    initialized: "init",
  },
  renameDirective: {
    reference: "ref",
  },
})

// Enable library.
doars.enable()

API

DoarsAlias

  • constructor Create plugin instance.
    • @param {Doars} library A doars library instance.
    • @param {Object} options = null See options.
    • @returns {DoarsAlias}

DoarsAlias options

  • {Object} aliasContexts The contexts to alias.
    • {Array<String>|String} [name] The alias or aliases of the context.
  • {Object} aliasDirectives The directives to alias.
    • {Array<String>|String} [name] The alias or aliases of the directive.
  • {Object} renameContexts The contexts to rename.
    • {String} [name] The new name of the context.
  • {Object} renameDirectives The directives to rename.
    • {String} [name] The new name of the directive.

Where [name] is the current name of the context or directive that should be aliased or renamed.

Compatible versions

@doars/doars-alias version @doars/doars version
1.x 1.x
2.x 2.x

Readme

Keywords

Package Sidebar

Install

npm i @doars/doars-alias

Weekly Downloads

0

Version

2.0.0

License

MIT

Unpacked Size

88.5 kB

Total Files

16

Last publish

Collaborators

  • redkenrok