Permalink
Browse files

Merge branch 'release/1.15'

* release/1.15:
  Update changelog
  Bump version to v1.15
  Add dmyers to the contributers list
  Add twig documentation
  Add new twig extension
  Bump copyright year to 2012
  Fix typos in quickref
  Fix typos in readme
  • Loading branch information...
2 parents 170c32b + c82b0c0 commit ef7f639713915cc43fc9681de82cf0db37d7687e @canton7 committed Apr 3, 2012
View
@@ -1,4 +1,4 @@
-Copyright (C) <2011> by <Antony Male>
+Copyright (C) <2012> by <Antony Male>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -16,4 +16,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
+THE SOFTWARE.
View
@@ -4,10 +4,10 @@
* Casset: Convenient asset library for FuelPHP.
*
* @package Casset
- * @version v1.14
+ * @version v1.15
* @author Antony Male
* @license MIT License
- * @copyright 2011 Antony Male
+ * @copyright 2012 Antony Male
* @link http://github.com/canton7/fuelphp-casset
*/
@@ -19,6 +19,7 @@
'Casset\\Casset_JSMin' => __DIR__.'/classes/casset/jsmin.php',
'Casset\\Casset_Csscompressor' => __DIR__.'/classes/casset/csscompressor.php',
'Casset\\Casset_Cssurirewriter' => __DIR__.'/classes/casset/cssurirewriter.php',
+ 'Casset\\Casset_Addons_Twig' => __DIR__.'/classes/casset/addons/twig.php',
));
/* End of file bootstrap.php */
View
@@ -3,6 +3,11 @@ Changelog
This file lists the important changes between versions. For a list of minor changes, check the log.
+v1.15
+----
+ - Add `render`, `render_js`, `render_css` and `img` to a new Twig extension. See `classes/casset/addons/readme.md`.
+ - Fix various typos.
+
v1.14
-----
- Add gen_tags option to render_js and render_css.
View
@@ -4,10 +4,10 @@
* Casset: Convenient asset library for FuelPHP.
*
* @package Casset
- * @version v1.14
+ * @version v1.15
* @author Antony Male
* @license MIT License
- * @copyright 2011 Antony Male
+ * @copyright 2012 Antony Male
* @link http://github.com/canton7/fuelphp-casset
*/
@@ -0,0 +1,23 @@
+Casset Addons
+=============
+
+Addons are extra classes which allow Casset to integrate with other third-party tools, in ways which are not possible using the callbacks.
+
+Currently there is only one addon: Twig.
+However, this will change if people require other addons.
+
+Twig
+----
+
+This extension adds the `Caset::render`, `Casset::render_js`, `Casset::render_css`, and `Casset::img` methods as twig functions (`render_assets`, `render_js`, `render_css`, and `img` respectively).
+
+To enable this extension, edit `config/parser.php`, and add `Casset_Addons_Twig` to the `extensions` key under 'View_Twig', like so:
+
+```php
+'View_Twig' => array(
+ 'extensions' => array(
+ 'Twig_Fuel_Extension',
+ 'Casset_Addons_Twig',
+ ),
+),
+```
@@ -0,0 +1,45 @@
+<?php
+
+/**
+ * Casset: Convenient asset library for FuelPHP.
+ *
+ * @package Casset
+ * @version v1.15
+ * @author Antony Male
+ * @author Derek Myers
+ * @license MIT License
+ * @copyright 2012 Antony Male
+ * @link http://github.com/canton7/fuelphp-casset
+ */
+
+namespace Casset;
+
+class Casset_Addons_Twig extends \Twig_Extension
+{
+ /**
+ * Gets the name of the extension.
+ *
+ * @return string
+ */
+ public function getName()
+ {
+ return 'casset';
+ }
+
+ /**
+ * Sets up all of the functions this extension makes available.
+ *
+ * @return array
+ */
+ public function getFunctions()
+ {
+ return array(
+ 'render_assets' => new \Twig_Function_Function('Casset::render'),
+ 'render_css' => new \Twig_Function_Function('Casset::render_css'),
+ 'render_js' => new \Twig_Function_Function('Casset::render_js'),
+ 'img' => new \Twig_Function_Function('Casset::img'),
+ );
+ }
+}
+
+/* End of file twig.php */
@@ -17,7 +17,7 @@
* This library is used as part of Casset.
*
* @package Casset
- * @version v1.14
+ * @version v1.15
* @author Antony Male
* @license MIT License
* @link http://github.com/canton7/fuelphp-casset
@@ -10,7 +10,7 @@
* This library is used as part of Casset.
*
* @package Casset
- * @version v1.14
+ * @version v1.15
* @author Antony Male
* @license MIT License
* @link http://github.com/canton7/fuelphp-casset
@@ -52,7 +52,7 @@
/**
* This library is used as part of Casset.
* @package Casset
- * @version v1.14
+ * @version v1.15
* @author Antony Male
* @license MIT License
* @link http://github.com/canton7/fuelphp-casset
View
@@ -3,10 +3,10 @@
* Casset: Convenient asset library for FuelPHP.
*
* @package Casset
- * @version v1.14
+ * @version v1.15
* @author Antony Male
* @license MIT License
- * @copyright 2011 Antony Male
+ * @copyright 2012 Antony Male
* @link http://github.com/canton7/fuelphp-casset
*/
View
@@ -302,7 +302,7 @@ Returns a set of `<script>`/`<link>` tag(s), as required.
`$group`: If false/null, render all groups. If a string, render just the named group.
-`$options': A set of options to control how/if the tags are rendered. See the docs for details.
+`$options`: A set of options to control how/if the tags are rendered. See the docs for details.
<a name="qr-render-js"></a>
### render_js
@@ -313,7 +313,7 @@ Returns a set of `<script>` tag(s), as required.
`$group`: If false/null, render all groups. If a string, render just the named group.
-`$options': A set of options to control how/if the tags are rendered. See the docs for details.
+`$options`: A set of options to control how/if the tags are rendered. See the docs for details.
<a name="qr-render-css"></a>
### render_css
@@ -324,7 +324,7 @@ Returns a set of `<link>` tag(s), as required.
`$group`: If false/null, render all groups. If a string, render just the named group.
-`$options': A set of options to control how/if the tags are rendered. See the docs for details.
+`$options`: A set of options to control how/if the tags are rendered. See the docs for details.
<a name="qr-render-js-inline"></a>
### render_js_inline
@@ -400,4 +400,4 @@ Cleares css files last modified before the given time.
`clear_css_cache($before = 'now')`.
-`$before`: The before which to delete cache files. any `strtotime`-compatible format allowed.
+`$before`: The before which to delete cache files. any `strtotime`-compatible format allowed.
View
@@ -202,7 +202,7 @@ Casset::add_group('test_group', array(
This method is provided merely for convenience when adding lots of files to a group at once.
You don't have to create a group before adding files to it -- the group will be created it it doesn't exist.
-You can change any of these options on-the-fly using `Casset::set_group_option($type, $group, $key, $value)`, or the CSS- and JS- specific versions, `Caset::set_js_option($group, $key, $value)` and `Casset::set_css_option($group, $key, $value)`.
+You can change any of these options on-the-fly using `Casset::set_group_option($type, $group, $key, $value)`, or the CSS- and JS- specific versions, `Casset::set_js_option($group, $key, $value)` and `Casset::set_css_option($group, $key, $value)`.
`$group` has some special values: an empty string is a shortcut to the 'global' group (to which files are added if a group is not specified), and '*' is a shortcut to all groups.
Multiple group names can also be specified, using an array.
@@ -391,7 +391,7 @@ You can also define dependencies when you call `Casset::add_group()`, by using t
Eg:
```php
-Caset::add_group('js', 'my_plugin', array('jquery.my_plugin.js'), array(
+Casset::add_group('js', 'my_plugin', array('jquery.my_plugin.js'), array(
'deps' => 'jquery',
));
```
@@ -662,7 +662,7 @@ Casset::render_js(false, array('gen_tags' => false));
Casset::set_group_option('js', 'global', 'inline', true);
Casset::render_js(false);
-// Returns <script type="text/javascript>Some javascript file content</script>
+// Returns <script type="text/javascript">Some javascript file content</script>
Casset::render_js(false, array('gen_tags' => false));
// Returns Array (
// [0] => "Some javascript file content"
@@ -814,6 +814,14 @@ In your .htaccess:
RewriteRule ^(.*)\/(.+)\.([0-9]+)\.(js|css|jpg|jpeg|gif|png)$ $1/$2.$4 [L]
```
+Addons
+------
+
+Casset also ships with the following addons, to easy integration wit third-party frameworks.
+For more details, see `classes/casset/addons/readme.md`.
+
+ - **Twig** - Adds the `render`, `render_js`, `render_css`, and `img` functions to Twig.
+
Comparison to Assetic
---------------------
@@ -909,6 +917,7 @@ The following people have helped Casset become what it is, so thank you!
- [monsonis](https://github.com/monsonis)
- [Anton Stoychev](https://github.com/antitoxic)
- [gnodeb](https://github.com/gnodeb)
+ - [Derek Myers](https://github.com/dmyers)
Contributing
------------
@@ -936,4 +945,4 @@ $ git rebase upstream/develop
# Force-push just this up to origin (as the rebase will have rewritten it)
$ git push -f origin feature/my_feature_branch
# Submit the pull request to github!
-```
+```

0 comments on commit ef7f639

Please sign in to comment.