These are chat archives for opal/opal

12th
Jul 2017
Jikku Jose
@JikkuJose
Jul 12 2017 04:04
@fkchang I think the most important reason people use React is JSX (beyond the obvious & powerful tech superiority). The components looks & feels like HTML that every one understands. Not an expert, but it may help if we can have JSX like dsl, not sure its even possible.
Elia Schito
@elia
Jul 12 2017 08:46

@JikkuJose @fkchang I'm quite sure it can be done with some compiler plugin and abusing heredocs, e.g.:

class HelloMessage < React::Component
  def render
    <<-JSX
      <div>Hello {@props[:name]}</div>
    JSX
  end
end

or some variant like <<-HTML which most editors will highlight as HTML:

<<-HTML
  <div>Hello {props.name}</div>
HTML
Jamie Gaskins
@jgaskins
Jul 12 2017 14:11
It could just be another stage in the asset pipeline: application.js.rb.jsx If a JSX compiler simply translates <div id="foo" /> to h('div', { id: 'foo' }) and ignores all other syntax, all you'd need is to define a Kernel#h method and it would just work.
Billy.Zheng
@zw963
Jul 12 2017 14:13

@JikkuJose @fkchang I'm quite sure it can be done with some compiler plugin and abusing heredocs, e.g.:

class HelloMessage < React::Component
  def render
    <<-JSX
      <div>Hello {@props[:name]}</div>
    JSX
  end
end

or some variant like <<-HTML which most editors will highlight as HTML:

<<-HTML
  <div>Hello {props.name}</div>
HTML

Pray not do like this!!
@Elia, Use HEREDOC is guly, and not syntax highlight + code format support, personal, i think this is a very bad idea.