Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow ability to have nested components #22

Open
edmondchuc opened this issue May 10, 2021 · 3 comments
Open

Allow ability to have nested components #22

edmondchuc opened this issue May 10, 2021 · 3 comments
Labels
enhancement New feature or request

Comments

@edmondchuc
Copy link

Inside templates/meld/todo.html, can I use {% meld 'counter' %} tag to have a nested component?

Example:

<!-- templates/meld/todo.html -->
<div>
    <form meld:submit.prevent="add" class="form-inline">
        <div class="form-group">
            <label for="todo-input" class="form-label">Add a new todo</label>
            <input meld:model.defer="todo_input" id="todo-input" type="text" autofocus>
            <button type="submit" class="btn btn-primary inline">Add</button>
        </div>
        
    </form>

    {% meld 'counter' %}

    <h2>Your todos</h2>
    {% for todo in todos %}
        <li class="mb-1 flashes">
            <div class="card">
                <div class="card-body">
                    <button meld:click="delete('{{ todo.id }}')" class="btn btn-danger mx-3">Remove</button>
                    {{ todo.todo }}
                </div>
            </div>
        </li>
    {% endfor %}
</div>

Currently when I try this, I get a KeyError:

venv\Lib\site-packages\flask_meld\component.py", line 257, in _set_values
    element.attrs["value"] = context_variables[element.attrs[model_attr]]
KeyError: 'state'
@mikeabrahamsen
Copy link
Owner

mikeabrahamsen commented May 10, 2021

I haven't implemented nesting meld tags but it is a feature I would love to support. I'll look into this.

@mikeabrahamsen mikeabrahamsen changed the title Is it possible to use jinja meld tag inside another meld template? Allow ability to have nested components May 17, 2021
@mikeabrahamsen
Copy link
Owner

Let's take a look at an example of how nesting may work:
https://laravel-livewire.com/docs/2.x/nesting-components

@mikeabrahamsen mikeabrahamsen added the enhancement New feature or request label May 17, 2021
@MohamedAliArafa
Copy link

Any update on this feature ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants