2017 © Pedro PelĂĄez
 

library meta-builder

Build meta data

image

ftv/meta-builder

Build meta data

  • Wednesday, May 11, 2016
  • by lepiaf
  • Repository
  • 12 Watchers
  • 0 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Meta data builder

This project is part of francetv zoom open source projects (iOS, Android and Angular)., (*1)

Help to build meta with php, (*2)

How to use

Extend AbstractMeta and implement getDefaultData();, (*3)

Data structure

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" />

Include templating

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)

The Versions

11/05 2016

dev-master

9999999-dev

Build meta data

  Sources   Download

MIT

The Development Requires

php meta builder