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

template iteration through dataset rows #18

Open
betrixed opened this issue Dec 21, 2020 · 1 comment
Open

template iteration through dataset rows #18

betrixed opened this issue Dec 21, 2020 · 1 comment

Comments

@betrixed
Copy link

Right now, I am exploring the hunt - dlang way of doing things. I have used dlang before, so it shouldn't be too much a learning curve. I am still looking through the source tree in the .dub/packages and guessing.

I have a Website in PHP. A common idiom is to do a database query, and pass results to a template as array of record objects, or array of array of key-value pairs.

Please, in your documentation, show how to pass results from
generic query for a record set with multiple fields, and multiple rows.

So I can get a query result, but how best to generate a template which can iterate multiple data rows?
At the moment, the view documentation suggests view.assign supports a named string value, or a named associative array, string[string].
There seems to be a possibility of the template execution being aware of the interfaces of the EntityRepository, ORM , and be able to iterate using the template macros.
I realize that interpreted AST templates will have limits, and this one would be a priority for any further progress for me.
It isn't easy, as some other project would have managed it already.

@aberba
Copy link

aberba commented Jan 16, 2021

@betrixed

Please, in your documentation, show how to pass results from
generic query for a record set with multiple fields, and multiple rows.

From data
and template

E.g.

string[] data = [...];

// data will be accessible in template
view.assign("data", data);

// render view
return view.render("home");
        <ol>
                {% for item in data %}
                        <li>{{ item}}</li>
                {% endfor %}
        </ol>

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

No branches or pull requests

2 participants