Move the HTML-specific code into a Lucky::HTML module #1441
Replies: 2 comments 8 replies
-
That's cool. That's actually a feature I was just evaluating. It's the 'V' of the MVC I was looking for! Ha! I was hoping to make something that works just like the /views directory in Rails does.
I've had this idea/pattern for my rails apps for the past 3 years and it's been working beautifully. So, think of Tailwind CSS and their idea of having predefined CSS utilities that control small aspects of the styling and can be combined as classes onto HTML pieces. Well why not have that as part of the pattern for displaying HTML? For example, let's say my sites theme has 3 types of buttons that could be used. I'd want to declare the styling with a placeholder that accepts. I'll use boostrap classes here because it's super well-known off the cusp. <button class="btn btn-primary btn-lg my-2 mx-3" additional_attributes() >#{button_text}</button>
<button class="btn btn-secondary btn-lg my-2 mx-3" additional_attributes()>#{button_text}</button>
<button class="btn btn-danger btn-lg my-2 mx-3" additional_attributes() >#{button_text}</button> In my mind, I would like to be able to call those buttons like a method, pass in parameters with the first being the tags contents and accepting a (forgive my ruby class reference here) Hash of keys/values and turning them into additional attributes on the tag. I'm clearly still very new to Crystal, but I'm super excited to get using this language on my projects and I think with the "utility first" approach that is emerging from the front-end world right now, it's something that could be adopted into Lucky and you'd be able to attract a lot more of the "utility first" crowd of full-stack developers. Hopefully that's pretty clear and easy to understand. And hopefully I understand what you were trying to describe. |
Beta Was this translation helpful? Give feedback.
-
Excellent idea ! I'm wondering (not convinced yet) if it's worth it to make Lucky::HTML its own shard in its own repo so that it could be used outside of Lucky. The drawback is that https://github.com/luckyframework has already so many children... :p Also, could this move make easier to use external templates system for those allergic to Lucky HTML DSL ? |
Beta Was this translation helpful? Give feedback.
-
Right now html code is mixed throughout the codebase. There's
Lucky::BaseComponent
andLucky::HTMLPage
and several modules in thelucky/page_helpers
directory but not in aLucky::PageHelpers
module.I think it would be best to make a module called
Lucky::HTML
andlucky/html
directory and move everything html related into it.What do you think?
Beta Was this translation helpful? Give feedback.
All reactions