Live data from Hacker News

RubyUI (Former PhlexUI): Ruby Gem for RubyUI Components

github.com

21–30 of 40 posts

Re: RubyUI (Former PhlexUI): Ruby Gem for RubyUI Components

#22

Phlex is an amazing project. Makes frontend fun again. I've built my own UI library using DaisyUI and Tailwindcss that we use in all our Rails projects: https://github.com/inhouse-work/protos It cannot be overstated how nice it is to move away from erb and into pure ruby. Private methods as partials is a game changer for refactoring your UI.

I increasingly wonder if I'm the only one left who genuinely likes erb :-D

Not a fan of the rails erb helper methods though, so maybe it doesn't count. I almost exclusively use it outside of rails now

Re: RubyUI (Former PhlexUI): Ruby Gem for RubyUI Components

#23

Phlex is an amazing project. Makes frontend fun again. I've built my own UI library using DaisyUI and Tailwindcss that we use in all our Rails projects: https://github.com/inhouse-work/protos It cannot be overstated how nice it is to move away from erb and into pure ruby. Private methods as partials is a game changer for refactoring your UI.

I increasingly wonder if I'm the only one left who genuinely likes erb :-D Not a fan of the rails erb helper methods though, so maybe it doesn't count. I almost exclusively use it outside of rails now

I don't know if I'm a fan but I've almost never had erb be the problem in a Rails app. The LLMs can work with it easily. Don't need to bring in extensions to work with major text editors. Sticking with ERB for now.

Re: RubyUI (Former PhlexUI): Ruby Gem for RubyUI Components

#24

Phlex is an amazing project. Makes frontend fun again. I've built my own UI library using DaisyUI and Tailwindcss that we use in all our Rails projects: https://github.com/inhouse-work/protos It cannot be overstated how nice it is to move away from erb and into pure ruby. Private methods as partials is a game changer for refactoring your UI.

Have you had much luck with slots? I have a project using View Components that leverages slots. I've tried migrating to Phlex, but the lack of explicit slot support has been a bit frustrating.

Slots are pretty easy in Phlex. Have a look at the README in the repo I linked for an idea. I just create `with_column` or `with_header` methods that take a block and store it.

To create them declaratively (not needing to call them in a set order) you just create a module that defines `before_template` and calls `vanish`: https://www.phlex.fun/miscellaneous/v2-upgrade.html#removed-...

Re: RubyUI (Former PhlexUI): Ruby Gem for RubyUI Components

#25

Phlex is an amazing project. Makes frontend fun again. I've built my own UI library using DaisyUI and Tailwindcss that we use in all our Rails projects: https://github.com/inhouse-work/protos It cannot be overstated how nice it is to move away from erb and into pure ruby. Private methods as partials is a game changer for refactoring your UI.

I increasingly wonder if I'm the only one left who genuinely likes erb :-D Not a fan of the rails erb helper methods though, so maybe it doesn't count. I almost exclusively use it outside of rails now

I found using partials between projects to be a headache. I wanted a way to standardize my UI for accessibility across all projects and not have to re-implement the same standards over and over. It's nice to be able to package the UI up into a gem and keep it maintained everywhere.

It's got a nice path for incremental adoption, so there is no need to go all-in unless you want to. Personally my Rails projects are all 95%+ ruby now.

Another nice knock off effect is that the LSP and integration with my IDE (neovim) is much nicer with Phlex components than it is with ERB.

I also think personally I don't like "magic" spaces like ERB where its hard for me to follow the code path. How does ERB manage multiline blocks with html in them? Hard to understand, harder to explain. To me it feels like there is less to worry about in Phlex where I'm thinking more in Ruby, less in the specifics of the view context.

Re: RubyUI (Former PhlexUI): Ruby Gem for RubyUI Components

#27
I used a rendering library like Phlex back in 2010. I hated it back then and I still don’t like it.

They claim it’s faster than ERB but only show micro benchmarks. This is basically a form of lying.

This approach stinks for a lot of reasons:

- it adds a ton of pressure on the garbage collector. - the backtraces suck to debug. Ruby is better now than in 2010, but it’s still lame. - your templates are largely static. Yet when it lives as code you can’t cache any of it. An efficient ERB generator is just cached strings concatenations. Very efficient in Ruby.

Finally, Rubyists hate this and it’s why the community is slowly dying. Almost all your frontend should be in JS/JSX at this point. Even the static stuff.

Re: RubyUI (Former PhlexUI): Ruby Gem for RubyUI Components

#28
post #9

Looks interesting, but I wish there was a way to alias the component names, since every component class, some of which have common names, take root in the global namespace. (though I suspect that easily enough done manually)

It's basically a code generator for adding standard Phlex components to your project, so once you've added a component to your application you can modify it any way you want.

And little by little we get closer to being Lisp-like...

Re: RubyUI (Former PhlexUI): Ruby Gem for RubyUI Components

#29
post #6

I’m impressed by this project’s progress. It’s more than just a render library. Although they claim it’s 12x faster than ERB, but I couldn’t find their benchmark.

I believe it's referencing this: https://github.com/KonnorRogers/view-layer-benchmarks

There were a few things off about the benchmarks so I made a pull request with some updates. The 12x claim is WAY off. https://github.com/KonnorRogers/view-layer-benchmarks/pull/2...
Post reply on HN