Skip to content

Commit

Permalink
class rename, return w/ no value
Browse files Browse the repository at this point in the history
  • Loading branch information
marionnewlevant committed Jun 20, 2016
1 parent bdfbbd7 commit e169a72
Show file tree
Hide file tree
Showing 17 changed files with 333 additions and 307 deletions.
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,20 @@ MN Twig Perversion works on Craft 2.4.x, Craft 2.5.x, Craft 2.6.x, and probably
{# do whatever... #}
{% endfor %}

`{% return %}` to return a value from a macro:
`{% return value %}` to return a value from a macro:

{% macro foo() %}
{# ... calculate someValue ... #}
{% return someValue %}
{% endmacro %}

`{% return %}` to return the empty string form a macro:

{% macro foo() %}
{# ... do stuff %}
{% return %}
{% endmacro %}

A macro with a `{% return %}` tag will return whatever the return value is (which can be a complex expression). Any other output generated by the macro will be discarded.

### Tests
Expand Down Expand Up @@ -80,4 +87,8 @@ The test will return false for hexadecimal strings as this will be the default b

* Fixed loop bug in `{% continue %}`

### 1.0.3 -- 2016.06.20

* Possibility of `{% return %}` with no value

Brought to you by [Marion Newlevant](http://marion.newlevant.com)
203 changes: 105 additions & 98 deletions mntwigperversion/MnTwigPerversionPlugin.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -17,112 +17,119 @@
class MnTwigPerversionPlugin extends BasePlugin
{

/**
* Returns the user-facing name.
*
* @return mixed
*/
public function getName()
{
return Craft::t('MN Twig Perversion');
}
/**
* Returns the user-facing name.
*
* @return mixed
*/
public function getName()
{
return Craft::t('MN Twig Perversion');
}

/**
* Plugins can have descriptions of themselves displayed on the Plugins page by adding a getDescription() method
* on the primary plugin class:
*
* @return mixed
*/
public function getDescription()
{
return Craft::t('Making twig do things it really shouldn\'t');
}
/**
* Plugins can have descriptions of themselves displayed on the Plugins page by adding a getDescription() method
* on the primary plugin class:
*
* @return mixed
*/
public function getDescription()
{
return Craft::t('Making twig do things it really shouldn\'t');
}

/**
* Plugins can have links to their documentation on the Plugins page by adding a getDocumentationUrl() method on
* the primary plugin class:
*
* @return string
*/
public function getDocumentationUrl()
{
return 'https://github.com/marionnewlevant/craft-twig_perversion';
}
/**
* Plugins can have links to their documentation on the Plugins page by adding a getDocumentationUrl() method on
* the primary plugin class:
*
* @return string
*/
public function getDocumentationUrl()
{
return 'https://github.com/marionnewlevant/craft-twig_perversion';
}

/**
* Plugins can now take part in Craft’s update notifications, and display release notes on the Updates page, by
* providing a JSON feed that describes new releases, and adding a getReleaseFeedUrl() method on the primary
* plugin class.
*
* @return string
*/
public function getReleaseFeedUrl()
{
return 'https://raw.githubusercontent.com/marionnewlevant/craft-twig_perversion/master/releases.json';
}
/**
* Plugins can now take part in Craft’s update notifications, and display release notes on the Updates page, by
* providing a JSON feed that describes new releases, and adding a getReleaseFeedUrl() method on the primary
* plugin class.
*
* @return string
*/
public function getReleaseFeedUrl()
{
return 'https://raw.githubusercontent.com/marionnewlevant/craft-twig_perversion/master/releases.json';
}

/**
* Returns the version number.
*
* @return string
*/
public function getVersion()
{
return '1.0.2';
}
/**
* Returns the version number.
*
* @return string
*/
public function getVersion()
{
return '1.0.3';
}

/**
* As of Craft 2.5, Craft no longer takes the whole site down every time a plugin’s version number changes, in
* case there are any new migrations that need to be run. Instead plugins must explicitly tell Craft that they
* have new migrations by returning a new (higher) schema version number with a getSchemaVersion() method on
* their primary plugin class:
*
* @return string
*/
public function getSchemaVersion()
{
return '1.0.0';
}
/**
* As of Craft 2.5, Craft no longer takes the whole site down every time a plugin’s version number changes, in
* case there are any new migrations that need to be run. Instead plugins must explicitly tell Craft that they
* have new migrations by returning a new (higher) schema version number with a getSchemaVersion() method on
* their primary plugin class:
*
* @return string
*/
public function getSchemaVersion()
{
return '1.0.0';
}

/**
* Returns the developer’s name.
*
* @return string
*/
public function getDeveloper()
{
return 'Marion Newlevant';
}
/**
* Returns the developer’s name.
*
* @return string
*/
public function getDeveloper()
{
return 'Marion Newlevant';
}

/**
* Returns the developer’s website URL.
*
* @return string
*/
public function getDeveloperUrl()
{
return 'http://marion.newlevant.com';
}
/**
* Returns the developer’s website URL.
*
* @return string
*/
public function getDeveloperUrl()
{
return 'http://marion.newlevant.com';
}

/**
* Returns whether the plugin should get its own tab in the CP header.
*
* @return bool
*/
public function hasCpSection()
{
return false;
}
/**
* Returns whether the plugin should get its own tab in the CP header.
*
* @return bool
*/
public function hasCpSection()
{
return false;
}

/**
* Add any Twig extensions.
*
* @return mixed
*/
public function addTwigExtension()
{
Craft::import('plugins.mntwigperversion.twigextensions.MnTwigPerversionTwigExtension');
/**
* Add any Twig extensions.
*
* @return mixed
*/
public function addTwigExtension()
{
Craft::import('plugins.mntwigperversion.twigextensions.MnTwigPerversionTwigExtension');
Craft::import('plugins.mntwigperversion.twigextensions.MnTwigPerversion_Break_Node');
Craft::import('plugins.mntwigperversion.twigextensions.MnTwigPerversion_Break_TokenParser');
Craft::import('plugins.mntwigperversion.twigextensions.MnTwigPerversion_Continue_Node');
Craft::import('plugins.mntwigperversion.twigextensions.MnTwigPerversion_Continue_TokenParser');
Craft::import('plugins.mntwigperversion.twigextensions.MnTwigPerversion_Return_Node');
Craft::import('plugins.mntwigperversion.twigextensions.MnTwigPerversion_Return_TokenParser');
// Craft::import('plugins.mntwigperversion.twigextensions.NumericTest');

return new MnTwigPerversionTwigExtension();
}
return new MnTwigPerversionTwigExtension();
}
}
Empty file modified mntwigperversion/resources/icon.svg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 0 additions & 32 deletions mntwigperversion/twigextensions/Break_TokenParser.php

This file was deleted.

39 changes: 0 additions & 39 deletions mntwigperversion/twigextensions/Continue_Node.php

This file was deleted.

32 changes: 0 additions & 32 deletions mntwigperversion/twigextensions/Continue_TokenParser.php

This file was deleted.

Loading

0 comments on commit e169a72

Please sign in to comment.