https://github.com/phly/phlyrequirejs
View helper for aggregating require()s for use with RequireJS-compatible libraries.
https://github.com/phly/phlyrequirejs
Last synced: about 1 year ago
JSON representation
View helper for aggregating require()s for use with RequireJS-compatible libraries.
- Host: GitHub
- URL: https://github.com/phly/phlyrequirejs
- Owner: phly
- Created: 2012-12-21T22:23:42.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2014-07-17T13:56:49.000Z (almost 12 years ago)
- Last Synced: 2025-04-01T18:12:04.981Z (about 1 year ago)
- Language: PHP
- Size: 137 KB
- Stars: 13
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
PhlyRequireJs
=============
[https://travis-ci.org/phly/PhlyRequireJs.svg?branch=master](https://travis-ci.org/phly/PhlyRequireJs)
Simple library providing a ZF2 view helper for aggregating RequireJs calls.
Installation
------------
Install the module via git submodules, unzipping the download zipball, or,
later, via Composer.
Enable it in a ZF2 module by adding the "PhlyRequireJs" module to your
`config/application.config.php` file.
If not using in ZF2, but standalone with the ZF2 `PhpRenderer`, you will need to
add the `requirejs` helper as an invokable to the `ViewHelperManager`.
Usage
-----
```php
requirejs()->append('foo/bar');
// require(["foo/bar"], function (bar) { bar.baz(); });
$this->requirejs()->append('foo/bar', 'function (bar) { bar.baz(); }');
// Capture the callback
$this->requirejs()->appendAndCaptureCallback('foo/bar'); ?>
function(bar) {
bar.baz();
bar.onClick(bar.doSomething);
}
requirejs()->stopCapture();
// Echo all requires
echo $this->requirejs();
```
The view helper also defines `prepend` and `prependAndCaptureCallback` methods;
they work identically, but prepend the require to the start of the list.
LICENSE
-------
BSD-2-Clause