I want to create some structure for the templates/ directory, which is
a mess right now. This is related to a number of confusing aspects of
Yesod, so let's start with a little Q&A:

Q. What is a Widget?

A. It is a section of a webpage. It can be just a little snippet of
html, or it can be a bundle of html, css, and javascript. The html of
a Widget can be anything from a little <li> to a gigantic <section>.

Q. How do I make a Widget?

A. A widget is created in Haskell. Haskellers have a variety of options
for making a Widget. They can be created from template files found in
the templates/ directory, or they can be created from templates
written directly in the Haskell files.

Q. How do I know if a template file (and the Widget it creates) is for
a particular page, or a form, or what?

A. You can't. There is nothing intrinsically tying the name of a
template file to a page on the website.

Q. I am writing a page and I want to use some custom form or other
helper Widget. How do I add it to my page?

A. The Widget you are going to use has to come from Haskell. There are
no other options. Even if you know the template file that creates the
Widget, you have to create the Widget in Haskell first before adding
it to your page.

I WANT TO CHANGE SOME OF THESE FACTS.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

First of all, I want there to be one, standard way of making Widgets.
Second, there are a few special categories of Widgets I want to make
explicit by their filenames.

So, here are my recommendations.

  - Every Widget is created from files under templates/. No
    quasiquotes, Haskellers, except for dire situations.

  - Top-level page Widgets are found under "templates/page/".

  - Top-level form Widgets are found under "templates/form/".

  - Widgets for custom form fields are found under "templates/field/".

  - Helper Widgets will live at the top-level (templates/) until
    more categories are discovered.

If nobody has a problem with these recommendations, here are the steps
we should take to implement them:

  1. Make sure each Widget is being generated from a template file.

    - We should probably break this task down into per-Haskell-file
      batches.

  2. Reorganize Widget files according to the given heirarchy.

Attachment: signature.asc
Description: Digital signature

_______________________________________________
Dev mailing list
Dev@lists.snowdrift.coop
https://lists.snowdrift.coop/mailman/listinfo/dev

Reply via email to