mixxorz / slippers

A UI component framework for Django. Built on top of Django Template Language.

Home Page:https://mitchel.me/slippers/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Docs: How does slippers solve the motivating example?

jmuncaster opened this issue · comments

In the docs I see this:

... Templates [...] are built and then included wherever they are needed.

{% url "project:add_data" as add_data_url %}
{% include "patterns/molecules/button/button.html" with label="Add data" href=add_data_url %}

And then it goes on to say:

As you can see, the syntax for this is quite verbose.

It would be great to see this exact example written in slippers. Perhaps I'm missing something really trivial, but I cannot see how the slippers code is much less verbose. Wouldn't it look like this?

{% url "project:add_data" as add_data_url %}
{% button with label="Add data" href=add_data_url %}

I can see how you don't have to type the full path to the partial, but everything else is more or less the same, which doesn't seem to support the verbosity claim very well. Am I missing something?

Not having to include the full path to the partial is a big deal if you're using a lot of {% include %} statements in your templates. It may not look like much from a single example, but having to write the path to the button component 30 times instead of just writing {% button %} is not insignificant in my opinion.

You also don't need with.

(Slightly unrelated, but the docs could be better written. Including this section.)

Thanks, I have begun to integrate slippers more and I can see how it reduces code (although at the expense of not being able to Cmd+Click the path in my IDE to bring the editor to the source).

I do think that the docs should show the solution to their motivating example. I wouldn't say this is unrelated, the clarity of the docs is exactly what this issue is about. The request would be to solve the motivating example in the docs, and/or lead with another example that better showcases this great library.

I came looking for this explanation. The library sounds like it should be useful, but TBH from reading the docs I'm not clear exactly on why it's better than just using include (it might become clearer once I build a more complicated frontend).