Skip to content

Commit

Permalink
fixed attributes broken on link shortcode
Browse files Browse the repository at this point in the history
added new gravstrap-list shortcode to handle a generic list
added new gravstrap-item shortcode to handle a generic html item
  • Loading branch information
giansi committed Feb 27, 2016
1 parent ee0b8ce commit f500e28
Show file tree
Hide file tree
Showing 9 changed files with 203 additions and 2 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# v1.0.0-rc.3
## 02/27/2016
1. [](#bugfix)
* fixed attributes broken on link shortcode

2.[](#new)
* Added new gravstrap-list shortcode to handle a generic list
* Added new gravstrap-item shortcode to handle a generic html item

# v1.0.0-rc.2
## 02/24/2016
1. [](#bugfix)
Expand Down
2 changes: 1 addition & 1 deletion blueprints.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Gravstrap
version: 1.0.0-rc.2
version: 1.0.0-rc.3
description: "Gravstrap is a Grav plugin that provides Bootstrap components as shortcodes. It has 30+ basic, modules and bootstrap shortcodes"
icon: share-alt
author:
Expand Down
57 changes: 57 additions & 0 deletions shortcodes/Basic/ItemShortcode.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php
/**
* This file is part of the Gravstrap plugin and it is distributed
* under the MIT License. To use this application you must leave
* intact this copyright notice.
*
* Copyright (c) Giansimon Diblas <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* For extra documentation and help please visit http://diblas.net
*
* @license MIT License
*
*/

namespace Grav\Plugin\Shortcodes;

use Thunder\Shortcode\Shortcode\ShortcodeInterface;

/**
* Class ItemShortcode handles a generic html item
*
* @author Giansimon Diblas
*/
class ItemShortcode extends GravstrapShortcode
{
/**
* {@inheritdoc}
*/
public function shortcodeName()
{
return 'gravstrap-item';
}

/**
* {@inheritdoc}
*/
protected function template()
{
return 'basic/item.html.twig';
}

/**
* {@inheritdoc}
*/
protected function renderOutput(ShortcodeInterface $shortcode)
{
return $this->grav['twig']->processTemplate($this->template(), [
'name' => $shortcode->getParameter('name'),
'tag' => $shortcode->getParameter('tag'),
'item_attributes' => $shortcode->getParameter('attributes'),
'content' => $shortcode->getContent(),
]);
}
}
2 changes: 1 addition & 1 deletion shortcodes/Basic/LinkShortcode.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ protected function renderOutput(ShortcodeInterface $shortcode)
'icon' => $shortcode->getParameter('icon'),
'icon_container' => $shortcode->getParameter('icon_container'),
'stacked' => $this->stringToBoolean($shortcode->getParameter('stacked')),
'attributes' => $shortcode->getParameter('attributes'),
'link_attributes' => $shortcode->getParameter('attributes'),
]);
}
}
58 changes: 58 additions & 0 deletions shortcodes/Basic/ListItemShortcode.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php
/**
* This file is part of the Gravstrap plugin and it is distributed
* under the MIT License. To use this application you must leave
* intact this copyright notice.
*
* Copyright (c) Giansimon Diblas <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* For extra documentation and help please visit http://diblas.net
*
* @license MIT License
*
*/

namespace Grav\Plugin\Shortcodes;

use Thunder\Shortcode\Shortcode\ShortcodeInterface;

/**
* Class ListItemShortcode handles a list item
*
* @author Giansimon Diblas
*/
class ListItemShortcode extends GravstrapShortcode
{
/**
* {@inheritdoc}
*/
public function shortcodeName()
{
return 'gravstrap-list-item';
}

/**
* {@inheritdoc}
*/
protected function template()
{
return 'basic/list-item.html.twig';
}

/**
* {@inheritdoc}
*/
protected function renderOutput(ShortcodeInterface $shortcode)
{
$output = $this->grav['twig']->processTemplate($this->template(), [
'name' => $shortcode->getParameter('name'),
'item_attributes' => $shortcode->getParameter('attributes'),
'content' => $shortcode->getContent(),
]);

return $output;
}
}
61 changes: 61 additions & 0 deletions shortcodes/Basic/ListShortcode.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php
/**
* This file is part of the Gravstrap plugin and it is distributed
* under the MIT License. To use this application you must leave
* intact this copyright notice.
*
* Copyright (c) Giansimon Diblas <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* For extra documentation and help please visit http://diblas.net
*
* @license MIT License
*
*/

namespace Grav\Plugin\Shortcodes;

use Gravstrap\Base\RegisteredShortcodes;
use Thunder\Shortcode\Shortcode\ShortcodeInterface;

/**
* Class ListShortcode handles a generic list
*
* @author Giansimon Diblas
*/
class ListShortcode extends GravstrapShortcode
{
/**
* {@inheritdoc}
*/
public function shortcodeName()
{
return 'gravstrap-list';
}

/**
* {@inheritdoc}
*/
protected function template()
{
return 'basic/list.html.twig';
}

/**
* {@inheritdoc}
*/
protected function renderOutput(ShortcodeInterface $shortcode)
{
$tag = null !== $shortcode->getParameter('tag') ? $shortcode->getParameter('tag') : 'ul';
$items = RegisteredShortcodes::get($this->shortcode->getId($shortcode));
$output = $this->grav['twig']->processTemplate($this->template(), [
'list_attributes' => $shortcode->getParameter('attributes'),
'items' => $items,
'tag' => $tag,
]);

return $output;
}
}
8 changes: 8 additions & 0 deletions templates/basic/item.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{% set attributes = parse_attributes(item_attributes) %}
{% if tag is not null %}
<{{ tag }} {% include 'partials/_attributes.html.twig' %}>
{% endif %}
{{ content }}
{% if tag is not null %}
</{{ tag }}>
{% endif %}
2 changes: 2 additions & 0 deletions templates/basic/list-item.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{% set attributes = parse_attributes(item_attributes) %}
<li {% include 'partials/_attributes.html.twig' %}>{{ content }}</li>
6 changes: 6 additions & 0 deletions templates/basic/list.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{% set attributes = parse_attributes(list_attributes) %}
<{{ tag }} {% include 'partials/_attributes.html.twig' %}>
{% for item in items %}
{{ item }}
{% endfor %}
</{{ tag }}>

0 comments on commit f500e28

Please sign in to comment.