[#82311] [Ruby trunk Bug#13794] Infinite loop of sched_yield — charlie@...
Issue #13794 has been reported by catphish (Charlie Smurthwaite).
4 messages
2017/08/09
[#82518] [Ruby trunk Feature#13618] [PATCH] auto fiber schedule for rb_wait_for_single_fd and rb_waitpid — mame@...
Issue #13618 has been updated by mame (Yusuke Endoh).
5 messages
2017/08/30
[#82552] Re: [Ruby trunk Feature#13618] [PATCH] auto fiber schedule for rb_wait_for_single_fd and rb_waitpid
— Eric Wong <normalperson@...>
2017/08/31
mame@ruby-lang.org wrote:
[#82756] Re: [Ruby trunk Feature#13618] [PATCH] auto fiber schedule for rb_wait_for_single_fd and rb_waitpid
— Eric Wrong <normalperson@...>
2017/09/12
Eric Wrong <normalperson@yhbt.net> wrote:
[ruby-core:82475] [Ruby trunk Feature#13839] String Interpolation Statements
From:
se8.and@...
Date:
2017-08-26 01:53:30 UTC
List:
ruby-core #82475
Issue #13839 has been updated by se8 (S辿bastien Durand).
> You should write expected code in valid Ruby syntax. Guessing from "%{3.times do}Hello #{'World'}%{end}", probably you intended:
>
> ~~~
> <<EOS
> {% if true %}
> Hello #{'World'}
> {% end %}
> EOS
> ~~~
>
It was an idea that we could maybe use a different notation: %{statement} instead of {% statement %} to be more similar to #{expression}
:)
----------------------------------------
Feature #13839: String Interpolation Statements
https://bugs.ruby-lang.org/issues/13839#change-66286
* Author: se8 (S辿bastien Durand)
* Status: Feedback
* Priority: Normal
* Assignee:
* Target version:
----------------------------------------
Hello!
Here is a KISS implementation of a template engine in Ruby:
~~~ ruby
class Template
attr_reader :input
def initialize(input)
@input = input
end
def output
"output = %\0" + @input.gsub("{%", "\0\n").gsub("%}", "\noutput += %\0") + "\0"
end
def render(binding)
eval(output, binding)
end
end
~~~
Usage:
~~~ text
{% if true %}
Hello #{'World'}
{% end %}
Template.new('...').render(binding)
~~~
It's kind of a hack on top of Ruby string interpolation, so it's hell fast (~4 times faster than ERB).
Could it be a good idea to implement this kind of statements directly in Ruby string interpolation? Maybe a syntax like that:
~~~ text
"%{3.times do}Hello #{'World'}%{end}"
~~~
So Ruby would have a fast minimal native template engine, with #{expressions} and %{statements}:
~~~ text
eval(File.read("..."), binding)
~~~
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>