-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 91d356d
Showing
13 changed files
with
492 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"pluginName":"Component-based Templating","pluginDescription":"Templating in a component-based environment","pluginVersion":"1.0.0","pluginAuthorName":"Pierre Stoffe","pluginVendorName":"pierrestoffe","pluginAuthorUrl":"https://pierrestoffe.be","pluginAuthorGithub":"pierrestoffe","codeComments":"yes","pluginComponents":["services","twigextensions","models"],"consolecommandName":"","controllerName":"","cpsectionName":"","elementName":"","fieldName":"","modelName":"","purchasableName":"","recordName":"","serviceName":"","taskName":"","utilityName":"","widgetName":"","apiVersion":"api_version_3_0"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Component-based Templating Changelog | ||
|
||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). | ||
|
||
## [Unreleased] | ||
|
||
## [1.0.0] - 2018-04-08 | ||
### Added | ||
- Initial release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
Copyright © Pierre Stoffe | ||
|
||
Permission is hereby granted to any person obtaining a copy of this software | ||
(the “Software”) to use, copy, modify, merge, publish and/or distribute copies | ||
of the Software, and to permit persons to whom the Software is furnished to do | ||
so, subject to the following conditions: | ||
|
||
1. **Don’t plagiarize.** The above copyright notice and this license shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
2. **Don’t use the same license on more than one project.** Each licensed copy | ||
of the Software shall be actively installed in no more than one production | ||
environment at a time. | ||
|
||
3. **Don’t mess with the licensing features.** Software features related to | ||
licensing shall not be altered or circumvented in any way, including (but | ||
not limited to) license validation, payment prompts, feature restrictions, | ||
and update eligibility. | ||
|
||
4. **Pay up.** Payment shall be made immediately upon receipt of any notice, | ||
prompt, reminder, or other message indicating that a payment is owed. | ||
|
||
5. **Follow the law.** All use of the Software shall not violate any applicable | ||
law or regulation, nor infringe the rights of any other person or entity. | ||
|
||
Failure to comply with the foregoing conditions will automatically and | ||
immediately result in termination of the permission granted hereby. This | ||
license does not include any right to receive updates to the Software or | ||
technical support. Licensees bear all risk related to the quality and | ||
performance of the Software and any modifications made or obtained to it, | ||
including liability for actual and consequential harm, such as loss or | ||
corruption of data, and any necessary service, repair, or correction. | ||
|
||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
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, INCLUDING SPECIAL, INCIDENTAL AND CONSEQUENTIAL DAMAGES, 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. |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
{ | ||
"name": "pierrestoffe/craft-component-based-templating", | ||
"description": "Templating in a component-based environment", | ||
"type": "craft-plugin", | ||
"version": "1.0.0", | ||
"keywords": [ | ||
"craft", | ||
"cms", | ||
"craftcms", | ||
"craft-plugin", | ||
"components", | ||
"dry" | ||
], | ||
"support": { | ||
"docs": "https://github.com/pierrestoffe/craft-component-based-templating/blob/master/README.md", | ||
"issues": "https://github.com/pierrestoffe/craft-component-based-templating/issues" | ||
}, | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Pierre Stoffe", | ||
"homepage": "https://pierrestoffe.be" | ||
} | ||
], | ||
"require": { | ||
"craftcms/cms": "^3.0.0" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"pierrestoffe\\componentbasedtemplating\\": "src/" | ||
} | ||
}, | ||
"extra": { | ||
"name": "Component-based Templating", | ||
"handle": "component-based-templating", | ||
"schemaVersion": "1.0.0", | ||
"hasCpSettings": false, | ||
"hasCpSection": false, | ||
"changelogUrl": "https://raw.githubusercontent.com/pierrestoffe/craft-component-based-templating/master/CHANGELOG.md", | ||
"components": { | ||
"componentsService": "pierrestoffe\\componentbasedtemplating\\services\\ComponentsService", | ||
"groupsService": "pierrestoffe\\componentbasedtemplating\\services\\GroupsService", | ||
"templatesService": "pierrestoffe\\componentbasedtemplating\\services\\TemplatesService" | ||
}, | ||
"class": "pierrestoffe\\componentbasedtemplating\\ComponentBasedTemplating" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
/** | ||
* Component-based Templating plugin for Craft CMS 3.x. | ||
* | ||
* Templating in a component-based environment | ||
* | ||
* @see https://pierrestoffe.be | ||
* | ||
* @copyright Copyright (c) 2018 Pierre Stoffe | ||
*/ | ||
|
||
namespace pierrestoffe\componentbasedtemplating; | ||
|
||
use Craft; | ||
use craft\base\Plugin; | ||
use pierrestoffe\componentbasedtemplating\models\Settings; | ||
use pierrestoffe\componentbasedtemplating\services\ComponentsService; | ||
use pierrestoffe\componentbasedtemplating\twigextensions\ComponentBasedTemplatingTwigExtension; | ||
|
||
/** | ||
* @author Pierre Stoffe | ||
* | ||
* @since 1.0.0 | ||
* | ||
* @property ComponentsService ComponentsService | ||
*/ | ||
class ComponentBasedTemplating extends Plugin | ||
{ | ||
// Static Properties | ||
// ========================================================================= | ||
|
||
/** | ||
* @var ComponentBasedTemplating | ||
*/ | ||
public static $plugin; | ||
|
||
// Public Methods | ||
// ========================================================================= | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function init() | ||
{ | ||
parent::init(); | ||
|
||
Craft::$app->view->registerTwigExtension(new ComponentBasedTemplatingTwigExtension()); | ||
} | ||
|
||
// Protected Methods | ||
// ========================================================================= | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function createSettingsModel() | ||
{ | ||
return new Settings(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
/** | ||
* Component-based Templating plugin for Craft CMS 3.x | ||
* | ||
* Templating in a component-based environment | ||
* | ||
* @link https://pierrestoffe.be | ||
* @copyright Copyright (c) 2018 Pierre Stoffe | ||
*/ | ||
|
||
/** | ||
* This file exists only as a template for the Component-based Templating settings. | ||
* It does nothing on its own. | ||
* | ||
* Don't edit this file, instead copy it to 'craft/config' as 'component-based-templating.php' | ||
* and make your changes there to override default settings. | ||
* | ||
* Once copied to 'craft/config', this file will be multi-environment aware as | ||
* well, so you can have different settings groups for each environment, just as | ||
* you do for 'general.php' | ||
*/ | ||
|
||
return [ | ||
// The name of the global variable used to call components in the templates | ||
'componentsName' => 'components', | ||
|
||
// The directory where the component files are kept | ||
'componentsPath' => '_components', | ||
|
||
// The name of the global variable used to call groups in the templates | ||
'groupsName' => 'groups', | ||
|
||
// The directory where the group files are kept | ||
'groupsPath' => '_groups' | ||
]; |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<?php | ||
/** | ||
* Component-based Templating plugin for Craft CMS 3.x. | ||
* | ||
* Templating in a component-based environment | ||
* | ||
* @see https://pierrestoffe.be | ||
* | ||
* @copyright Copyright (c) 2018 Pierre Stoffe | ||
*/ | ||
|
||
namespace pierrestoffe\componentbasedtemplating\models; | ||
|
||
use craft\base\Model; | ||
|
||
/** | ||
* @author Pierre Stoffe | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
class Settings extends Model | ||
{ | ||
// Public Properties | ||
// ========================================================================= | ||
|
||
/** | ||
* The name of the global variable used to call components in the templates. | ||
* | ||
* @var array | ||
*/ | ||
public $componentsName = 'components'; | ||
|
||
/** | ||
* The directory where the component files are kept. | ||
* | ||
* @var array | ||
*/ | ||
public $componentsPath = '_components'; | ||
|
||
/** | ||
* The name of the global variable used to call groups in the templates. | ||
* | ||
* @var array | ||
*/ | ||
public $groupsName = 'groups'; | ||
|
||
/** | ||
* The directory where the group files are kept. | ||
* | ||
* @var array | ||
*/ | ||
public $groupsPath = '_groups'; | ||
|
||
// Public Methods | ||
// ========================================================================= | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function rules() | ||
{ | ||
return [ | ||
['componentsName', 'string'], | ||
['componentsName', 'default', 'value' => 'components'], | ||
|
||
['componentsPath', 'string'], | ||
['componentsPath', 'default', 'value' => '_components'], | ||
|
||
['groupsName', 'string'], | ||
['groupsName', 'default', 'value' => 'groups'], | ||
|
||
['groupsPath', 'string'], | ||
['groupsPath', 'default', 'value' => '_groups'], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
/** | ||
* Component-based Templating plugin for Craft CMS 3.x. | ||
* | ||
* Templating in a component-based environment | ||
* | ||
* @see https://pierrestoffe.be | ||
* | ||
* @copyright Copyright (c) 2018 Pierre Stoffe | ||
*/ | ||
|
||
namespace pierrestoffe\componentbasedtemplating\services; | ||
|
||
use Craft; | ||
use craft\base\Component; | ||
use pierrestoffe\componentbasedtemplating\ComponentBasedTemplating; | ||
|
||
/** | ||
* @author Pierre Stoffe | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
class ComponentsService extends Component | ||
{ | ||
// Public Methods | ||
// ========================================================================= | ||
|
||
/** | ||
* @param string $method | ||
* @param array $variables | ||
* | ||
* @return @void | ||
*/ | ||
public function __call($method, $variables) | ||
{ | ||
$name = ComponentBasedTemplating::getInstance()->getSettings()->componentsName; | ||
$templatePath = ComponentBasedTemplating::getInstance()->getSettings()->componentsPath; | ||
|
||
$templatesService = new TemplatesService(); | ||
|
||
echo $templatesService->getTemplate($method, $variables, $name, $templatePath); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
/** | ||
* Component-based Templating plugin for Craft CMS 3.x. | ||
* | ||
* Templating in a component-based environment | ||
* | ||
* @see https://pierrestoffe.be | ||
* | ||
* @copyright Copyright (c) 2018 Pierre Stoffe | ||
*/ | ||
|
||
namespace pierrestoffe\componentbasedtemplating\services; | ||
|
||
use Craft; | ||
use craft\base\Component; | ||
use pierrestoffe\componentbasedtemplating\ComponentBasedTemplating; | ||
|
||
/** | ||
* @author Pierre Stoffe | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
class GroupsService extends Component | ||
{ | ||
// Public Methods | ||
// ========================================================================= | ||
|
||
/** | ||
* @param string $method | ||
* @param array $variables | ||
* | ||
* @return @void | ||
*/ | ||
public function __call($method, $variables) | ||
{ | ||
$name = ComponentBasedTemplating::getInstance()->getSettings()->groupsName; | ||
$templatePath = ComponentBasedTemplating::getInstance()->getSettings()->groupsPath; | ||
|
||
$templatesService = new TemplatesService(); | ||
|
||
echo $templatesService->getTemplate($method, $variables, $name, $templatePath); | ||
} | ||
} |
Oops, something went wrong.