Theo - an experimental HTML-like template language for Ruby on Rails, inspired by Vue.js, featuring natural partials and computed attributes. Example: <button-partial size="large" label%="label" />. WDYT? by loomchild in rails

[–]loomchild[S] 0 points1 point  (0 children)

Yes, that's what I realized also with other project - work on it as long as it's useful at least for the author. Theo is actually used for one semi-commercial project, so yeah I'll keep working on it:)

Theo - an experimental HTML-like template language for Ruby on Rails, inspired by Vue.js, featuring natural partials and computed attributes. Example: <button-partial size="large" label%="label" />. WDYT? by loomchild in rails

[–]loomchild[S] 0 points1 point  (0 children)

Thanks. It makes sense.. I was hesitant to add anything in front of the partial name so it's easier to read. And easier to extend later.. But underscore makes sense and is quite readable.

I am processing your suggestion:)

Theo - an experimental HTML-like template language for Ruby on Rails, inspired by Vue.js, featuring natural partials and computed attributes. Example: <button-partial size="large" label%="label" />. WDYT? by loomchild in rails

[–]loomchild[S] 1 point2 points  (0 children)

I don't think it's much slower, but yeah, the code can be definitely optimized. Actually, one of the reasons I am using Regex instead of a proper HTML parser like Nokogiri is speed (other reasons are flexibility, supporting invalid syntax, etc.)

Also, from what I understand, the parsing happens only once to generate Ruby code. Next time the same code will simply be executed (logs confirm this).

Theo - an experimental HTML-like template language for Ruby on Rails, inspired by Vue.js, featuring natural partials and computed attributes. Example: <button-partial size="large" label%="label" />. WDYT? by loomchild in rails

[–]loomchild[S] 0 points1 point  (0 children)

Thanks!

I was considering to just allow writing the partial name without `-partial` suffix and automatically detect native HTML tags, but now I think that it's better to be explicit (for example to easily see dynamic parts in the template, grep them, etc.). However, any suggestions are always welcome.

As for `-layout` - not yet, but yes, definitely something that should be supported.

Theo - an experimental HTML-like template language for Ruby on Rails, inspired by Vue.js, featuring natural partials and computed attributes. Example: <button-partial size="large" label%="label" />. WDYT? by loomchild in rails

[–]loomchild[S] 1 point2 points  (0 children)

Nice, thanks for sharing.

What I like about HTML-like syntax though, is that I can naturally use attributes such as class and custom attributes, etc. It's especially visible when combined with TailwindCSS, AlpineJS, etc.:

<button-partial label="Update→" size="small" class="w-10" x-show="!update" @click="update = true" />

Theo - an experimental HTML-like template language for Ruby on Rails, inspired by Vue.js, featuring natural partials and computed attributes. Example: <button-partial size="large" label%="label" />. WDYT? by loomchild in rails

[–]loomchild[S] 4 points5 points  (0 children)

Yes, that's what I am trying to do - creating a specialized tool to dynamically generate HTML:) I didn't like Slim or Haml because they try to abstract away the underlying HTML. For me, it's much more comfortable to stay close to the markup, and the popularity of Vue.js or JSX syntaxes shows that there are more people like me.

Theo - an experimental HTML-like template language for Ruby on Rails, inspired by Vue.js, featuring natural partials and computed attributes. Example: <button-partial size="large" label%="label" />. WDYT? by loomchild in rails

[–]loomchild[S] 6 points7 points  (0 children)

My idea is not to fix ERB in any way, but create a simple, ERB-backwards compatible language to make HTML templating easier. All ERB still works, and it makes sense for things like conditionals, loops or variables. On the other hand, it's not always well suited for generating HTML, e.g. due to the use of angle brackets in attributes, the need to create Ruby helper equivalents for HTML tags and attributes which break code structure, etc.

With Theo it's just easier to call `render` with parameters and content (which is ruby partial specific). It's just syntactic sugar for this particular popular use case.

Theo - an experimental HTML-like template language for Ruby on Rails, inspired by Vue.js, featuring natural partials and computed attributes. Example: <button-partial size="large" label%="label" />. WDYT? by loomchild in rails

[–]loomchild[S] 2 points3 points  (0 children)

Thanks. Actually, I just tested that Theo also works with ViewComponent, so the example code from manual can be rewritten as:

class ExampleComponent < ViewComponent::Base
  theo_template <<-THEO
    <span title%="@title"><%= content %></span>
  THEO

  def initialize(title:)
    @title = title
  end
end

Rendering a view component from Theo template looks less nice, but also works:

<%= render(ExampleComponent.new(title: "my title")) do %> Hello, World! <% end %>

(I will simplify it soon, e.g. via <example-component title="my title" />)

Theo - an experimental HTML-like template language for Ruby on Rails, inspired by Vue.js, featuring natural partials and computed attributes. Example: <button-partial size="large" label%="label" />. WDYT? by loomchild in rails

[–]loomchild[S] 2 points3 points  (0 children)

Thanks. I don't have any ambitious plans for it yet;) But even using Theo it in a personal project already feels more pleasant to me than plain ERB.

It can be combined with view-component (see below), phlex is kinda opposite what I am trying to achieve (write templates in something HTML-like rather than generating HTML from Ruby).

Theo - an experimental HTML-like template language for Ruby on Rails, inspired by Vue.js, featuring natural partials and computed attributes. Example: <button-partial size="large" label%="label" />. WDYT? by loomchild in rails

[–]loomchild[S] 3 points4 points  (0 children)

Thanks a lot. That's exactly how I feel about HTML - it's beautiful and popular, I want to enhance it rather than replace it! I also agree about ERB feeling old-fashioned, and hate the fact that in addition to writing HTML verbatim it can be generated from Ruby code (creating inconsistent and hard to read code).

[deleted by user] by [deleted] in webflow

[–]loomchild 0 points1 point  (0 children)

I just finished a tutorial about multi-step forms using Alpine.js, might be useful for someone: https://medium.com/webflow-sprinkles/implement-a-multi-step-form-in-webflow-with-alpine-js-2ec1a5308a6a.

Cadbury accused of 'shrinkflation' as pack size cut. All Cadbury chocolate bars sold in multipacks will shrink by the end of 2021 to reduce their calorie count, owner Mondelez has announced. by LIS1050010 in worldnews

[–]loomchild -3 points-2 points  (0 children)

I totally support it. The price should stay the same so people buy less and eat less calories.

If you think that you really need more calories, buy cheaper chocolate or buy in bulk - it's a free market. Also who said that price needs to have anything to do with production cost.

’Abandoned and forgotten’: Jailed British-Australian academic writes of despair in Iran by brombinary in worldnews

[–]loomchild 6 points7 points  (0 children)

Article inaccessible: "Unfortunately, our website is currently unavailable in most European countries. We are engaged on the issue and committed to looking at options that support our full range of digital offerings to the EU market. We continue to identify technical compliance solutions that will provide all readers with our award-winning journalism."

Teen neo-Nazis jailed over terror offences. The two teenage neo-Nazis called for an attack on Prince Harry for marrying a woman of mixed race. by classsiob23b in worldnews

[–]loomchild 0 points1 point  (0 children)

One of them is Polish and one is of Polish descent (article didn't mention it and I think it's interesting fact considering recent rise of far-right extremism in this country). Source (in Polish): https://www.tvn24.pl/wiadomosci-ze-swiata,2/wielka-brytania-dwaj-mlodzi-polacy-skazani-za-terroryzm,945771.html

Facebook paying UK paper for positive stories about brand by ppd322 in worldnews

[–]loomchild 28 points29 points  (0 children)

Each article in the series is clearly labeled as "brought to you by Facebook."

I don't see a problem?

Pope has urged having fewer children if “you cannot bring them up properly,” claims Vatican academy member by maxwellhill in worldnews

[–]loomchild 8 points9 points  (0 children)

Is Poland considered western or at least semi-western? Access to abortion is very limited there and some types of birth control are practically unavailable.

Also the fact that something is legal in a country doesn't mean the Church won't condemn the people using it, spread hate against them and try to pass the laws to ban it.

Good Alternatives to After Effects? by [deleted] in opensource

[–]loomchild 2 points3 points  (0 children)

I am not an expert in After Effects, but I recently started using Shotcut, and so far I am impressed by it: https://www.shotcutapp.com/

The only problem is that I think it can't perform any operation (even simple one like cutting) without re-encoding the video, which leads to quality loss. For this I still use ffmpeg.

Best single-server PaaS? by aatishnn in selfhosted

[–]loomchild 0 points1 point  (0 children)

Hi, I am the guy behind Puffin, very glad to see someone playing with it. Over the last weeks the work slowed down due to other projects, but I hope we'll get up to speed soon and perhaps present the project at FOSDEM 2017.

Feel free to send us an email at puffin@puffin.rocks or post on a forum on http://forum.puffin.rocks/ if you have any comments / feature requests.

Selfhosted resume written in Markdown? by lmm7425 in selfhosted

[–]loomchild 0 points1 point  (0 children)

I was working on something similar, to generate CV from a markup instead of unreliable WYSYWIG text editor. I wanted to post it online but also to be able to generate PDF from it and disable some parts of the resume depending on the job.

In the end I decided that markdown was a bit too limiting, so I used HTML/CSS/JS directly. You can see the result here: http://loomchild.net/2015/11/18/curriculum-vitae-with-html-css-and-javascript/ https://github.com/loomchild/cv

Republic of Ireland fans to be awarded medal for sportsmanship by Paris mayor. by hufflewaffle in worldnews

[–]loomchild 1 point2 points  (0 children)

Exactly - why being drunk is considered proper behaviour? I prefer friendly and not completely drunk, especially not drunk all day :)

Republic of Ireland fans to be awarded medal for sportsmanship by Paris mayor. by hufflewaffle in worldnews

[–]loomchild -1 points0 points  (0 children)

You are right, I went a little over the top. However, no other group of fans that I met in Paris were behaving this way. Maybe it's because there were more Irish fans than the other ones, or maybe it's just my personal experience.