GithubHelp home page GithubHelp logo

twig-components's People

Contributors

arnaudligny avatar giorgiopogliani avatar kurtrank avatar nevmn avatar pindagus avatar rasmuswinter avatar ryanscherler avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

twig-components's Issues

Subfolders (namespaces)

Have you considered adding support for namespaces or subfolders?

An example: I'm making a bunch of components called intro or header that lives in different contexts and often are very different.

Thus I want to group them in subfolders, say blog/intro.twig, faq/intro.twig etc.

Would it make sense to add support for prefixes to ComponentTokenParser, and then use the folder structure as a prefix?

Say, something like blogIntro, faqIntro etc.? If you nest folders, it would just keep adding it.

So if you have blog/view/intro.twig that would turn into blogViewIntro.

x-component name shows in rendered output html

I am using Symfony 5.3. Installed the extension.

I tried to add the extension in my services.yaml like this

E_USER_DEPRECATED

The "Twig\TokenParser\IncludeTokenParser" class is considered internal. It may change without further notice. You should not use it from "Performing\TwigComponents\ComponentTokenParser".

parameters:
  app.name: '%env(APP_NAME)%'
  app.upload_dir: '%kernel.project_dir%/%env(APP_UPLOAD_DIR)%'
  app.upload_uri: '%env(APP_UPLOAD_DIR)%'
  app.upload_max_filesize: '%env(APP_UPLOAD_MAX_FILESIZE)%'

services:
  _defaults:
    autowire: true      # Automatically injects dependencies in your services.
    autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.

  App\:
    resource: '../src/'
    exclude:
      - '../src/DependencyInjection/'
      - '../src/Entity/'
      - '../src/Kernel.php'
      - '../src/Tests/'

  componentextension:
    lazy: false
    class: Performing\TwigComponents\ComponentExtension
    tags:
      - {name: twig.extension}
    arguments:
      $relativePath: '%kernel.project_dir%/templates/components/'

when i try to use it in my template it shows like
Screenshot_2021-09-24_08-46-49

code for my button.twig component

<button {{ attributes.merge({ class:'text-white rounded-md px-4 py-2' }) }}>
  {{ slot }}
</button>

Adding a controller

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?

Component file names

How would you handle filenames with kebab-case filenames, eg page-header.twig?

Is Twig nodes always lowercase?

Usage with Symfony ?

Hello, thanks for your awesome work !
I'm sorry if this is obvious, but i'm trying to use this with a symfony 6 app and i have no idea how to configure this package...

Since twig is somehow autoloaded by symfony I don't how to use the configuration snippet you provide (where and how ?)

/** @var \Twig\Environment $twig */

use Performing\TwigComponents\Configuration;

Configuration::make($twig)
    ->setTemplatesPath('/relative/directory/to/components')
    ->setTemplatesExtension('twig')
    ->useCustomTags()
    ->setup();

TwigComponents

I actually started a very similar project https://github.com/TwigComponents one day before your first commit ;-)
You are still ahead since your code is open source, mine isn't.

Is there any reason why you stuck with the 0.1.0 release?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.