dev-master
9999999-devBuild meta data
MIT
The Development Requires
php meta builder
Wallogit.com
2017 © Pedro PelĂĄez
Build meta data
This project is part of francetv zoom open source projects (iOS, Android and Angular)., (*1)
Help to build meta with php, (*2)
Extend AbstractMeta and implement getDefaultData();, (*3)
public function getDefaultData()
{
return [
"name_of_meta" => [
["attribute name" => "value of attribute", "second attribute name" => "value of attribute"],
]
]
}
Then,, (*4)
echo $meta->buildHtml(
$meta->getDefaultData()
);
<meta attribute name="value of attribute" second attribute name="value of attribute" />
Extend constructor to add templating service. For example, twig., (*5)
private $templating;
public function __construct($rootUrl, $uri, $templating)
{
$this->templating = $templating;
}
public function buildHtml($meta)
{
return $this->templating->render('meta/meta.html', ['metas' => $meta]);
}
In your twig, (*6)
{% block meta %}
{% for meta in metas %}
{% for attrs in meta %}
{% spaceless %}
<meta
{% for (attrKey, attrValue) in $attrs %}
{{ attrKey }}="{{ attrValue }}"
{% endfor %}
/>
{% endspaceless %}
{% endfor %}
{% endfor %}
{% endblock %}
You may use some macro to refactor it., (*7)
Build meta data
MIT
php meta builder