Dancer::Plugin::SimpleCRUD use of template
Dear Dancers, Enjoying Dancer::Plugin::SimpleCRUD. Really a great tool. Just one thing I'm having a problem with is the use of a template. Is it possible to adjust the view that comes out of the box and where can I find this view? If not then reading the docs it says that: "a template must have a "simple_crud" placeholder defined or you won't get any output. This template must be located in your "views" directory." This maybe should all be obvious but setting up a view with [% render_content %] doesn't work. Should I define all database fields in the template? Thanks, Gert
Hi Gert, On 10/03/14 06:04, Gert van Oss wrote:
Dear Dancers,
Enjoying Dancer::Plugin::SimpleCRUD. Really a great tool.
Just one thing I'm having a problem with is the use of a template. Is it possible to adjust the view that comes out of the box and where can I find this view?
If not then reading the docs it says that: "a template must have a "simple_crud" placeholder defined or you won't get any output. This template must be located in your "views" directory."
What the documentation is saying here (which arguably might be made clearer) is your template requires a token with the name 'simple_crud' like so: [% simple_crud %]
This maybe should all be obvious but setting up a view with
[% render_content %]
doesn't work. Should I define all database fields in the template?
Replace this with the one above, and you should see the SimpleCRUD output in your template. Cheers, JamesR -- James Ronan
Hi James, I see, though my main.tt layout is still in the background. I guess that whatever template in the /views the plugin always uses the main.tt as layout? As I was confused by the docs saying: Any global layout will be applied automatically because this option causes the module to use the template keyword. Changing look of the template comes down to changing to code in the SimpleCrud.pm I see. Thanks, Gert On 10 Mar 2014, at 10:22, James Ronan <james@ronanweb.co.uk> wrote:
Hi Gert,
On 10/03/14 06:04, Gert van Oss wrote:
Dear Dancers,
Enjoying Dancer::Plugin::SimpleCRUD. Really a great tool.
Just one thing I'm having a problem with is the use of a template. Is it possible to adjust the view that comes out of the box and where can I find this view?
If not then reading the docs it says that: "a template must have a "simple_crud" placeholder defined or you won't get any output. This template must be located in your "views" directory."
What the documentation is saying here (which arguably might be made clearer) is your template requires a token with the name 'simple_crud' like so:
[% simple_crud %]
This maybe should all be obvious but setting up a view with
[% render_content %]
doesn't work. Should I define all database fields in the template?
Replace this with the one above, and you should see the SimpleCRUD output in your template.
Cheers, JamesR
-- James Ronan _______________________________________________ dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
On Mon, 10 Mar 2014 10:55:46 +0100 Gert van Oss <gertvanoss@me.com> wrote:
I see, though my main.tt layout is still in the background. I guess that whatever template in the /views the plugin always uses the main.tt as layout? As I was confused by the docs saying:
Any global layout will be applied automatically because this option causes the module to use the template keyword.
Yeah - that used to be the case - looks like when I changed the code to always apply layout I forgot to update that bit of the docs. Will sort that out - ta. The bit of D::P::SimpleCRUD's code that does that is: sub _apply_template { my ($html, $template) = @_; if ($template) { return template $template, { simple_crud => $html }; } else { return engine('template')->apply_layout($html); } }
Changing look of the template comes down to changing to code in the SimpleCrud.pm I see.
You should be able to do quite a bit just with your CSS, to be fair. I had thought there was an option to provide additional options to HTML::Table::FromDatabase when rendering the table to view records, so you could e.g. give that table a specific ID, or alternating classes for even & odd rows, etc - if that would be useful I can add that. Cheers Dave P
The bit of D::P::SimpleCRUD's code that does that is:
For now with not to many routes in place changing the default layout to something like ‘database’ adjusting the other accordingly works perfect.
You should be able to do quite a bit just with your CSS, to be fair.
Thanks, that is a good option to go for. Gert On 10 Mar 2014, at 11:04, David Precious <davidp@preshweb.co.uk> wrote:
The bit of D::P::SimpleCRUD's code that does that is:
participants (3)
-
David Precious -
Gert van Oss -
James Ronan