Skip to content

Adding a controller #19

@broskees

Description

@broskees

I'd really like to place a controller between the component and the template, for example:

{# /components/templates/table.twig #}
{% spaceless %}
    <table {{ attributes.merge({}) }}>
        {% if caption is not empty %}
            <caption {{ caption.attributes }}>
              {{ caption }}
            </caption>
        {% endif %}
        {% for row in rows %}
            <tr {{ row.attributes.merge({}) }}>
                {% for cell in column %}
                    <{{ cell.type }} {{ cell.attributes.merge({}) }}>{{ cell.label ?: '&nbsp;' }}</{{ cell.type }}>
                {% endfor %}
            </tr>
        {% endfor %}
    </table>
{% endspaceless %}
<?php
/**
 * /components/controllers/table.php
 */
 
class table
{
  public function __construct($attributes)
  {
    if (!isset($attributes['caption']) {
      throw new Error("You must define a caption to keep this accessible");
    }
  }
}

Is there any way to implement something like this with this library?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions