SlideShare a Scribd company logo
RubyKaigi2009



 Erubis

makoto kuwata <kwa@kuwata-lab.com>
     http://www.kuwata-lab.com/




    copyright(c) 2009 kuwata-lab.com all rights reserved.
                                                                            1
‣

‣




    copyright(c) 2009 kuwata-lab.com all rights reserved.
                                                            2
Agenda

  ‣ Part 1.   Erubis
  ‣ Part 2.   eRuby
  ‣ Part 3.




              copyright(c) 2009 kuwata-lab.com all rights reserved.
                                                                      3
Part 1. Erubis



     copyright(c) 2009 kuwata-lab.com all rights reserved.
                                                             4
Erubis

   ‣ pure Ruby             eRuby
   ‣
       • http://jp.rubyist.net/magazine/?0022-FasterThanC
   ‣
       •                  HTML
       •
       • PHP, Java, JS, C, Perl, Scheme
       • ...
               copyright(c) 2009 kuwata-lab.com all rights reserved.
                                                                       5
Ruby program:
 require 'rubygems' #
 require 'erubis'
 str = File.read('template.eruby')
 eruby = Erubis::Eruby.new(str)
 print eruby.result(binding())
command-line:
 $ erubis template.eruby #
 $ erubis -x template.eruby # Ruby
 $ erubis -z template.eruby #

           copyright(c) 2009 kuwata-lab.com all rights reserved.
                                                                   6
HTML
str =<<END           <%= %>
<%= var %>           <%== %>
<%== var %>
END
eruby = Erubis::Eruby.new(str, :escape=>true)
puts eruby.result(:var=>"<B&B>")

output:
 &lt;B&am;&gt;
 <B&B>
                                                    (choosability)

            copyright(c) 2009 kuwata-lab.com all rights reserved.
                                                                     7
‣       <% %>                                      [% %]
[% for x in @list %]
 <li>[%= x %]</li>
[% end %]                                                          !
## Ruby
Erubis::Eruby.new(str, :pattern=>'[% %]')
## command-line
$ erubis -p '[% %]' file.eruby

           copyright(c) 2009 kuwata-lab.com all rights reserved.
                                                                       8
Binding                                 Hash Object
Hash                                       Object
hash = {                                   @title = "Example"
  :title => "Example",                     @items = [1, 2, 3]
  :items => [1, 2, 3], }                   erubis =
erubis =                                     Erubis::Eruby.new(str)
  Erubis::Eruby.new(str)                   puts erubis.evaluate(self)
puts erubis.result(hash)

<h1><%= title%></h1>                        <h1><%= @title%></h1>
<% for x in items %>                        <% for x in @items %>
<% end %>                                   <% end %>
              copyright(c) 2009 kuwata-lab.com all rights reserved.
                                                                        9
Enhancer
   ‣ Erubis                                             module
   ## <%= %> HTML
   module EscapeEnhancer
     def add_expr(src, code, indicator)
       if indicator == '='
          src << " _buf<<escapeXml(#{code})"
       elsif indicator == '=='
          src << " _buf<<(#{code}).to_s;"
       end
     end          Erubis
   end

              copyright(c) 2009 kuwata-lab.com all rights reserved.
                                                                      10
Enhancer (cont')

  ###                         Enhancer
  ### (     : print()       )
  module StdoutEnhancer            _buf=""
    def add_preamble(src)             _buf=$stdout
      src << "_buf = $stdout;"
    end
    def add_postamble(src)
      src << "n""n"
    end                    _buf.to_s
  end                           "" (        )

              copyright(c) 2009 kuwata-lab.com all rights reserved.
                                                                      11
Enhancer

                                               include/extend
  ### Ruby
  class MyEruby < Erubis::Eruby
     include Erubis::EscapeEnhancer
     include Erubis::PercentLineEnhancer
  end
  puts MyEruby.new(str).result(:items=>[1,2,3])

                                                  ,
  ### command-line
  $ erubis -E Escape,Percent file.eruby

             copyright(c) 2009 kuwata-lab.com all rights reserved.
                                                                     12
Enhancer

‣ EscapeEnhancer :               HTML

‣ PercentLineEnhancer :        '%'

‣ InterporationEnhancer : _buf<<"#{ }"
‣ DeleteIndentEnhancer : HTML
‣ StdoutEnhancer : _buf=""           _buf=$stdout

‣ ...      (erubis -h                   )

            copyright(c) 2009 kuwata-lab.com all rights reserved.
                                                                    13
‣                                                            (
                  )

### command-line
$ erubis -c '{arr: [A, B, C]}' template.eruby # YAML
$ erubis -c '@arr=%w[A B C]' template.eruby # Ruby

<% for x in @arr %>                                  <li>A</li>
<li><%= x %></li>                                    <li>B</li>
<% end %>                                            <li>C</li>

             copyright(c) 2009 kuwata-lab.com all rights reserved.
                                                                     14
‣    *.yaml                              *.rb

$ erubis -f data.yaml template.eruby # YAML
$ erubis -f data.rb template.eruby # Ruby
data.yaml                            data.rb
 title: Example                       @title = "Example"
 items:                               @items =
   - name: Foo                         [ {"name"=>"Foo"},
   - name: Bar                           {"name"=>"Bar"}, ]

            copyright(c) 2009 kuwata-lab.com all rights reserved.
                                                                    15
‣ <%===           %>

<%=== @var %>                                                      2

### Ruby
$stderr.puts("*** debug: @var=#{@var.inspect}")

###
*** debug: @var=["A", "B", "C"]


           copyright(c) 2009 kuwata-lab.com all rights reserved.
                                                                       16
‣ PHP, Java, JS, C, Perl,Scheme                                      (       )

 <% for (i=0; i<n; i++) { %>                                    (C       )
 <li><%= "%d", i %>        printf()
 <% } %>

#line 1 "file.ec"          (erubis -xl c file.ec                           )
 for (i=0; i<n; i++) {
fputs("<li>", stdout); fprintf(stdout, "%d", i);
fputs("n", stdout); }

             copyright(c) 2009 kuwata-lab.com all rights reserved.
                                                                                 17
‣ Erubis
  •                       HTML
  •
  • Enhancer
  •                                     /
  •
  • PHP, Java, JS, C, Perl, Scheme
           copyright(c) 2009 kuwata-lab.com all rights reserved.
                                                                   18
Part 2. eRuby



     copyright(c) 2009 kuwata-lab.com all rights reserved.
                                                             19
‣ binding()

      •
i=0                                                  ### file.erb
str = File.read('file.erb')                           <% for i in 1..3 %>
ERB.new(str).result(binding)                         <li><%= i %></li>
p i #=> 3                                            <% end %>
                                       !

             copyright(c) 2009 kuwata-lab.com all rights reserved.
                                                                           20
‣ binding()

  •
  •

 b = Bingind.new
 b[:title] = "Example"                                            …
 b[:items] = [1, 2, 3]

          copyright(c) 2009 kuwata-lab.com all rights reserved.
                                                                      21
ERB

‣(                )
‣ Struct
  • http://d.hatena.ne.jp/m_seki/20080528/1211909590

  Foo = Struct.new(:title, :items)
  class Foo
   def env; binding(); end
  end
  ctx = Foo.new("Example", [1,2,3])
  ERB.new(str).result(ctx.env)
           copyright(c) 2009 kuwata-lab.com all rights reserved.
                                                                   22
Erubis

  ‣ Binding                               Hash

erubis.result(:items=>[1, 2, 3])

def result(b=TOPLEVEL_BINDING)
  if b.is_a?(Hash)
     s = b.collect{|k,v| "#{k}=b[#{k.inspect}];"}.join
     b = binding()
     eval s, b                  Binding
  end
  return eval(@src, b)
end
              copyright(c) 2009 kuwata-lab.com all rights reserved.
                                                                      23
Erubis

‣ Binding                      Object
@items = [1, 2, 3];              <% for x in @items %>
erubis.evaluate(self)            <% end %>

def evaluate(ctx)                               Hash
  if ctx.is_a?(Hash)
     hash = ctx; ctx = Object.new
     hash.each {|k,v|
       ctx.instance_variable_set("@#{k}", v) }
  end
  return ctx.instance_eval(@src)
end       copyright(c) 2009 kuwata-lab.com all rights reserved.
                                                                  24
ERB
1. 8.6   Erubis::Eruby

                  ERB
1. 8.7   Erubis::Eruby

                  ERB
1.9.1    Erubis::Eruby
                           0                   10                   20          30
                                                                                (sec)


                                                                             (by eval)
                                                                         (eRuby→Ruby)
                copyright(c) 2009 kuwata-lab.com all rights reserved.
                                                                                         25
ERB

‣
‣
    •
class Foo
   extend ERB::DefMethod
   def_erb_method('render', 'template.erb')
end
print Foo.new.render

          copyright(c) 2009 kuwata-lab.com all rights reserved.
                                                                  26
Erubis

‣
    •                         Ruby                          *.cache
    •2                 *.cache


eruby = Erubis::Eruby.load_file("file.eruby")
print eruby.result()
                        CGI


          copyright(c) 2009 kuwata-lab.com all rights reserved.
                                                                      27
Erubis

‣                         Proc
    •
    •

                                                 instance_eval
def evaluate(ctx)                                 Proc
  @proc ||= eval(@src)
  ctx.instance_eval(@proc)
end

         copyright(c) 2009 kuwata-lab.com all rights reserved.
                                                                 28
‣
       •   HTML

                                                   <ul>
<ul>
<% for x in @list %>                                  <li>AAA</li>
 <li><%= x %></li>
<% end %>                                             <li>BBB</li>
</ul>
                                                   </ul>
             copyright(c) 2009 kuwata-lab.com all rights reserved.
                                                                     29
ERB

‣                       trim mode
    • ">" :         "%>"
    • "<>" :        "<%"                               "%>"
    • "-" : "<%-" "-%>"
    • "%" : "%"
    • "%>", "%<>", "-" : "%"                    ">"/"<>"/"-"

    ERB.new(str, nil, "%<>")

            copyright(c) 2009 kuwata-lab.com all rights reserved.
                                                                    30
Erubis

‣
    • <%     %>
    • <%=      %>

<ul>                                                     <ul>
<% for x in @list %>                                       AAA
  <%= x %>                                                 BBB
<% end %>                                                  CCC
</ul>                                                    </ul>

            copyright(c) 2009 kuwata-lab.com all rights reserved.
                                                                    31
ERB                               Erubis
eRuby
                                ×                     (                  )
                      (                         )

                                ×
                  (                                 ) (                  )

                                ×                     (                  )
                          (                 )

        copyright(c) 2009 kuwata-lab.com all rights reserved.
                                                                             32
‣

    • [ruby-list:18894] eRuby                                      (?)

‣

    • <% %>        <%= %>
    •

           copyright(c) 2009 kuwata-lab.com all rights reserved.
                                                                         33
‣       <%=          %>                                               HTML
                                                                !
    • eRuby                                                           HTML


    •
‣                                                                            ?


              copyright(c) 2009 kuwata-lab.com all rights reserved.
                                                                                 34
ERB

‣(                     )
‣
     •
         String
     • http://www2a.biglobe.ne.jp/~seki/ruby/erbquote.html



                  copyright(c) 2009 kuwata-lab.com all rights reserved.
                                                                          35
Erubis

‣                              Erubis
    •
eruby = Erubis::Eruby.new(str, :escape=>true)
# or eruby = Erubis::EscapedEruby.new(str)
puts eruby.evaluate(ctx)

Hi <%= @name %>! #
Hi <%== @name %>! #

         copyright(c) 2009 kuwata-lab.com all rights reserved.
                                                                 36
<% unless @items.blank? %>
<table>
 <tbody>
   <% @items.each do |item| %>
   <tr class="item" id="item-<%=item.id%>">
     <td class="item-id"><%= item.id %></td>
     <td class="item-name">
       <% if item.url && !item.url.empty? %>
       <a href="<%= item.url %>"><%=item.name%></a>
       <% else %>
       <span><%=item.name%></span>
       <% end %>
     </td>
   </tr>                            HTML Ruby
   <% end %>
 </tbody>                           end
</table>                            (do     end 100                    )
<% end %>


               copyright(c) 2009 kuwata-lab.com all rights reserved.
                                                                           37
ERB

‣               (                         erb -x                 )

$ erb -x foo.eruby
_erbout = ''; unless @items.blank? ;
_erbout.concat "n"
_erbout.concat "<table>n"
_erbout.concat " <tr class="record">n"

$ erb -x foo.eruby | ruby -wc
Syntax OK
         copyright(c) 2009 kuwata-lab.com all rights reserved.
                                                                     38
Erubis

‣
    • -x : Ruby
    • -X : HTML
    • -N :                      (number)
    • -U :                               1           (unique)
    • -C :                                         (compact)
    • -z :
             copyright(c) 2009 kuwata-lab.com all rights reserved.
                                                                     39
$ cat foo.eruby
<% unless @items.blank? %>
<table>
 <% @items.each_with_index do|x, i| %>
 <tr class="record">
   <td><%= i +1 %></td>
   <td><%=h x %></td>
 </tr>
 <% end %>
</table>
<% end %>


         copyright(c) 2009 kuwata-lab.com all rights reserved.
                                                                 40
-x       Ruby
$ erubis -x foo.eruby
_buf = ''; unless @items.blank?
 _buf << '<table>
'; @items.each_with_index do|x, i|
 _buf << ' <tr class="record">
    <td>'; _buf << ( i +1 ).to_s; _buf << '</td>
    <td>'; _buf << (h x ).to_s; _buf << '</td>
  </tr>
'; end
 _buf << '</table>
'; end
_buf.to_s

           copyright(c) 2009 kuwata-lab.com all rights reserved.
                                                                   41
-X
$ erubis -X foo.eruby
_buf = ''; unless @items.blank?

 @items.each_with_index do|x, i|

       _buf << ( i +1 ).to_s;
       _buf << (h x ).to_s;

 end

 end
_buf.to_s

            copyright(c) 2009 kuwata-lab.com all rights reserved.
                                                                    42
-N                  (number)
$ erubis -XN foo.eruby
   1: _buf = ''; unless @items.blank?
   2:
   3: @items.each_with_index do|x, i|
   4:
   5:       _buf << ( i +1 ).to_s;
   6:       _buf << (h x ).to_s;
   7:
   8: end
   9:
  10: end
  11: _buf.to_s

          copyright(c) 2009 kuwata-lab.com all rights reserved.
                                                                             43
-U                     (uniq)
$ erubis -XNU foo.eruby
   1: _buf = ''; unless @items.blank?

  3:   @items.each_with_index do|x, i|

  5:         _buf << ( i +1 ).to_s;
  6:         _buf << (h x ).to_s;

  8:   end

 10: end
 11: _buf.to_s

          copyright(c) 2009 kuwata-lab.com all rights reserved.
                                                                       44
-C                   (compact)
$ erubis -XNC foo.eruby
   1: _buf = ''; unless @items.blank?
   3: @items.each_with_index do|x, i|
   5:       _buf << ( i +1 ).to_s;
   6:       _buf << (h x ).to_s;
   8: end
  10: end
  11: _buf.to_s




          copyright(c) 2009 kuwata-lab.com all rights reserved.
                                                                              45
<%= %>


<%= form_for :user do %>
 <div>
  <%= text_field :name %>
 </div>
<% end %>                eRuby


         copyright(c) 2009 kuwata-lab.com all rights reserved.
                                                                 46
<%=             %>

<%= 10.times do %>
Hello
<% end %>


                                                                   !
_buf = "";
_buf << ( 10.times do ).to_s;
_buf << " Hellon";
 end
          copyright(c) 2009 kuwata-lab.com all rights reserved.
                                                                       47
ERB+Rails

   ‣                                                    (_erbout)
                                                                    !


                                                form_for()
             …                                  _erbout

<% form_for do %>                        _erbout = ""
Hello                                    form_for do
<% end %>                                 _erbout.concat("Hello")
                                         end

           copyright(c) 2009 kuwata-lab.com all rights reserved.
                                                                        48
Erubis+Merb

   ‣ Erubis

<%= form_for do %>                            @_buf << (form_for do;
Hello                                         @_buf << "Hellon"
<% end =%>                                    end);




              copyright(c) 2009 kuwata-lab.com all rights reserved.
                                                                       49
‣ eRuby
‣                                                  (kool!)
‣
    •                                                             @_buf


‣

          copyright(c) 2009 kuwata-lab.com all rights reserved.
                                                                          50
‣ eRuby
            eRuby
  •
  •
  •
  •
  •                     HTML
  •
  •

          copyright(c) 2009 kuwata-lab.com all rights reserved.
                                                                  51
Part 3.



          copyright(c) 2009 kuwata-lab.com all rights reserved.
                                                                  52
‣
<ul>                                            print "<ul>n"
<% for x in @a %>                               for x in @a
 <li><%=x%></li>                                print "<li>#{x}</li>n"
<% end %>                                       end
</ul>                                           print "</u>n"




            copyright(c) 2009 kuwata-lab.com all rights reserved.
                                                                          53
<ul>                                s = File.read('foo.eruby')
<li><%=x%></li>                     e = Erubis::Eruby.new(s)
</ul>                               puts e.evaluate(:x=>1)




          copyright(c) 2009 kuwata-lab.com all rights reserved.
                                                                  54
‣                                                               ?


<%#ARGS: items, name='guest' %>
Hello <%= name %>!
<% for x in items %>
<li><%=x%></li>
<% end %>



          copyright(c) 2009 kuwata-lab.com all rights reserved.
                                                                      55
‣ HTML
      •
<html>                                            <html>
<body>
                                                  <body>              !(   )
                                                  </body>
 <h1><%=@title%></h1>                             </html>
 <ul id="menulist">
  <% for x in @items %>                           <h1><%=@title%></h1>
  <li><%=x%></li>                                 <ul id="menulist">
                                                  </ul>
  <% end %>
 </ul>                                            <% for x in @items %>
</body>                                            <li><%= x %></li>
</html>                                           <% end %>
              copyright(c) 2009 kuwata-lab.com all rights reserved.
                                                                               56
‣ Django

....
{% block pagetitle %}
<h1>{{title}}</h1>
{% endblock %}
....                                                 (method override)


             copyright(c) 2009 kuwata-lab.com all rights reserved.
                                                                         57
AOP

  ‣ AOP : Aspect Oriented Programming
    •                                                              /

<table>
           "for x in @a"                            •HTML
 <tr>
  <td>     "print x"
 </tr>                                              •
           "end"
</table>
                                                           (           )

           copyright(c) 2009 kuwata-lab.com all rights reserved.
                                                                           58
‣ HTML                              View
  •                                                                  …

‣ HTML     String
 (http://www.oiwa.jp/~yutaka/tdiary/20051229.html)
 •                       /
 •                                          Python str unicode
 •   HTML+String
 •             HTML                                          (SQL    )

             copyright(c) 2009 kuwata-lab.com all rights reserved.
                                                                         59
‣
‣

    •                                                           AOP …

‣


        copyright(c) 2009 kuwata-lab.com all rights reserved.
                                                                        60
‣
    • http://jp.rubyist.net/magazine/?0024-TemplateSystem
‣
   • http://jp.rubyist.net/magazine/?0024-TemplateSystem2
‣ Erubis
   • http://www.kuwata-lab.com/erubis/
‣
    • http://www.kuwata-lab.com/tenjin/

               copyright(c) 2009 kuwata-lab.com all rights reserved.
                                                                       61
one more thing

   copyright(c) 2009 kuwata-lab.com all rights reserved.
                                                           62
Tenjin - template engine replacing eRuby

 ‣ ERB    Erubis
   • eRuby
   •
 ‣ Tenjin :
   •                                                                   /
   •
     -                                                                ...
   • http://www.kuwata-lab.com/tenjin/
              copyright(c) 2009 kuwata-lab.com all rights reserved.
                                                                            63
thank you

 copyright(c) 2009 kuwata-lab.com all rights reserved.
                                                         64

More Related Content

What's hot

Python高级编程(二)
Python高级编程(二)Python高级编程(二)
Python高级编程(二)
Qiangning Hong
 
Working with databases in Perl
Working with databases in PerlWorking with databases in Perl
Working with databases in Perl
Laurent Dami
 
Perl.Hacks.On.Vim
Perl.Hacks.On.VimPerl.Hacks.On.Vim
Perl.Hacks.On.VimLin Yo-An
 
Just-In-Time Compiler in PHP 8
Just-In-Time Compiler in PHP 8Just-In-Time Compiler in PHP 8
Just-In-Time Compiler in PHP 8
Nikita Popov
 
Puppet Camp Paris 2015: Power of Puppet 4 (Beginner)
Puppet Camp Paris 2015: Power of Puppet 4 (Beginner) Puppet Camp Paris 2015: Power of Puppet 4 (Beginner)
Puppet Camp Paris 2015: Power of Puppet 4 (Beginner)
Puppet
 
PL/Perl - New Features in PostgreSQL 9.0
PL/Perl - New Features in PostgreSQL 9.0PL/Perl - New Features in PostgreSQL 9.0
PL/Perl - New Features in PostgreSQL 9.0
Tim Bunce
 
Letswift19-clean-architecture
Letswift19-clean-architectureLetswift19-clean-architecture
Letswift19-clean-architecture
Jung Kim
 
A Functional Guide to Cat Herding with PHP Generators
A Functional Guide to Cat Herding with PHP GeneratorsA Functional Guide to Cat Herding with PHP Generators
A Functional Guide to Cat Herding with PHP Generators
Mark Baker
 
Good Evils In Perl
Good Evils In PerlGood Evils In Perl
Good Evils In PerlKang-min Liu
 
lldb – Debugger auf Abwegen
lldb – Debugger auf Abwegenlldb – Debugger auf Abwegen
lldb – Debugger auf Abwegen
inovex GmbH
 
Perl.Hacks.On.Vim Perlchina
Perl.Hacks.On.Vim PerlchinaPerl.Hacks.On.Vim Perlchina
Perl.Hacks.On.Vim Perlchinaguestcf9240
 
Interceptors: Into the Core of Pedestal
Interceptors: Into the Core of PedestalInterceptors: Into the Core of Pedestal
Interceptors: Into the Core of Pedestal
Kent Ohashi
 
Being functional in PHP (DPC 2016)
Being functional in PHP (DPC 2016)Being functional in PHP (DPC 2016)
Being functional in PHP (DPC 2016)
David de Boer
 
AnyMQ, Hippie, and the real-time web
AnyMQ, Hippie, and the real-time webAnyMQ, Hippie, and the real-time web
AnyMQ, Hippie, and the real-time webclkao
 
Advanced Python, Part 2
Advanced Python, Part 2Advanced Python, Part 2
Advanced Python, Part 2
Zaar Hai
 
Ruby 2.0
Ruby 2.0Ruby 2.0
Ruby 2.0
Uģis Ozols
 
Perl.Hacks.On.Vim Perlchina
Perl.Hacks.On.Vim PerlchinaPerl.Hacks.On.Vim Perlchina
Perl.Hacks.On.Vim PerlchinaLin Yo-An
 
Imugi: Compiler made with Python
Imugi: Compiler made with PythonImugi: Compiler made with Python
Imugi: Compiler made with Python
Han Lee
 
Introdução ao Perl 6
Introdução ao Perl 6Introdução ao Perl 6
Introdução ao Perl 6
garux
 
Being functional in PHP (PHPDay Italy 2016)
Being functional in PHP (PHPDay Italy 2016)Being functional in PHP (PHPDay Italy 2016)
Being functional in PHP (PHPDay Italy 2016)
David de Boer
 

What's hot (20)

Python高级编程(二)
Python高级编程(二)Python高级编程(二)
Python高级编程(二)
 
Working with databases in Perl
Working with databases in PerlWorking with databases in Perl
Working with databases in Perl
 
Perl.Hacks.On.Vim
Perl.Hacks.On.VimPerl.Hacks.On.Vim
Perl.Hacks.On.Vim
 
Just-In-Time Compiler in PHP 8
Just-In-Time Compiler in PHP 8Just-In-Time Compiler in PHP 8
Just-In-Time Compiler in PHP 8
 
Puppet Camp Paris 2015: Power of Puppet 4 (Beginner)
Puppet Camp Paris 2015: Power of Puppet 4 (Beginner) Puppet Camp Paris 2015: Power of Puppet 4 (Beginner)
Puppet Camp Paris 2015: Power of Puppet 4 (Beginner)
 
PL/Perl - New Features in PostgreSQL 9.0
PL/Perl - New Features in PostgreSQL 9.0PL/Perl - New Features in PostgreSQL 9.0
PL/Perl - New Features in PostgreSQL 9.0
 
Letswift19-clean-architecture
Letswift19-clean-architectureLetswift19-clean-architecture
Letswift19-clean-architecture
 
A Functional Guide to Cat Herding with PHP Generators
A Functional Guide to Cat Herding with PHP GeneratorsA Functional Guide to Cat Herding with PHP Generators
A Functional Guide to Cat Herding with PHP Generators
 
Good Evils In Perl
Good Evils In PerlGood Evils In Perl
Good Evils In Perl
 
lldb – Debugger auf Abwegen
lldb – Debugger auf Abwegenlldb – Debugger auf Abwegen
lldb – Debugger auf Abwegen
 
Perl.Hacks.On.Vim Perlchina
Perl.Hacks.On.Vim PerlchinaPerl.Hacks.On.Vim Perlchina
Perl.Hacks.On.Vim Perlchina
 
Interceptors: Into the Core of Pedestal
Interceptors: Into the Core of PedestalInterceptors: Into the Core of Pedestal
Interceptors: Into the Core of Pedestal
 
Being functional in PHP (DPC 2016)
Being functional in PHP (DPC 2016)Being functional in PHP (DPC 2016)
Being functional in PHP (DPC 2016)
 
AnyMQ, Hippie, and the real-time web
AnyMQ, Hippie, and the real-time webAnyMQ, Hippie, and the real-time web
AnyMQ, Hippie, and the real-time web
 
Advanced Python, Part 2
Advanced Python, Part 2Advanced Python, Part 2
Advanced Python, Part 2
 
Ruby 2.0
Ruby 2.0Ruby 2.0
Ruby 2.0
 
Perl.Hacks.On.Vim Perlchina
Perl.Hacks.On.Vim PerlchinaPerl.Hacks.On.Vim Perlchina
Perl.Hacks.On.Vim Perlchina
 
Imugi: Compiler made with Python
Imugi: Compiler made with PythonImugi: Compiler made with Python
Imugi: Compiler made with Python
 
Introdução ao Perl 6
Introdução ao Perl 6Introdução ao Perl 6
Introdução ao Perl 6
 
Being functional in PHP (PHPDay Italy 2016)
Being functional in PHP (PHPDay Italy 2016)Being functional in PHP (PHPDay Italy 2016)
Being functional in PHP (PHPDay Italy 2016)
 

Similar to Erubis徹底解説

BioMake PAG 2017
BioMake PAG 2017 BioMake PAG 2017
BioMake PAG 2017
Chris Mungall
 
Hacking with ruby2ruby
Hacking with ruby2rubyHacking with ruby2ruby
Hacking with ruby2ruby
Marc Chung
 
How to Begin to Develop Ruby Core
How to Begin to Develop Ruby CoreHow to Begin to Develop Ruby Core
How to Begin to Develop Ruby Core
Hiroshi SHIBATA
 
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011Nick Sieger
 
The secret of programming language development and future
The secret of programming  language development and futureThe secret of programming  language development and future
The secret of programming language development and future
Hiroshi SHIBATA
 
Ruby on Rails 3.1: Let's bring the fun back into web programing
Ruby on Rails 3.1: Let's bring the fun back into web programingRuby on Rails 3.1: Let's bring the fun back into web programing
Ruby on Rails 3.1: Let's bring the fun back into web programing
Bozhidar Batsov
 
Charla EHU Noviembre 2014 - Desarrollo Web
Charla EHU Noviembre 2014 - Desarrollo WebCharla EHU Noviembre 2014 - Desarrollo Web
Charla EHU Noviembre 2014 - Desarrollo Web
Mikel Torres Ugarte
 
Connecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRubyConnecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRuby
Nick Sieger
 
Practical Testing of Ruby Core
Practical Testing of Ruby CorePractical Testing of Ruby Core
Practical Testing of Ruby Core
Hiroshi SHIBATA
 
Socket applications
Socket applicationsSocket applications
Socket applicationsJoão Moura
 
Your own (little) gem: building an online business with Ruby
Your own (little) gem: building an online business with RubyYour own (little) gem: building an online business with Ruby
Your own (little) gem: building an online business with RubyLindsay Holmwood
 
Minicurso Ruby e Rails
Minicurso Ruby e RailsMinicurso Ruby e Rails
Minicurso Ruby e Rails
SEA Tecnologia
 
Play vs Rails
Play vs RailsPlay vs Rails
Play vs Rails
Daniel Cukier
 
Debugging of (C)Python applications
Debugging of (C)Python applicationsDebugging of (C)Python applications
Debugging of (C)Python applications
Roman Podoliaka
 
Hiveminder - Everything but the Secret Sauce
Hiveminder - Everything but the Secret SauceHiveminder - Everything but the Secret Sauce
Hiveminder - Everything but the Secret Sauce
Jesse Vincent
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with ClojureDmitry Buzdin
 
How to Begin Developing Ruby Core
How to Begin Developing Ruby CoreHow to Begin Developing Ruby Core
How to Begin Developing Ruby Core
Hiroshi SHIBATA
 
Distributed, Incremental Dataflow Processing on AWS with GRAIL's Reflow (CMP3...
Distributed, Incremental Dataflow Processing on AWS with GRAIL's Reflow (CMP3...Distributed, Incremental Dataflow Processing on AWS with GRAIL's Reflow (CMP3...
Distributed, Incremental Dataflow Processing on AWS with GRAIL's Reflow (CMP3...
Amazon Web Services
 
Crossing the Bridge: Connecting Rails and your Front-end Framework
Crossing the Bridge: Connecting Rails and your Front-end FrameworkCrossing the Bridge: Connecting Rails and your Front-end Framework
Crossing the Bridge: Connecting Rails and your Front-end Framework
Daniel Spector
 

Similar to Erubis徹底解説 (20)

BioMake PAG 2017
BioMake PAG 2017 BioMake PAG 2017
BioMake PAG 2017
 
Hacking with ruby2ruby
Hacking with ruby2rubyHacking with ruby2ruby
Hacking with ruby2ruby
 
How to Begin to Develop Ruby Core
How to Begin to Develop Ruby CoreHow to Begin to Develop Ruby Core
How to Begin to Develop Ruby Core
 
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
 
Gun make
Gun makeGun make
Gun make
 
The secret of programming language development and future
The secret of programming  language development and futureThe secret of programming  language development and future
The secret of programming language development and future
 
Ruby on Rails 3.1: Let's bring the fun back into web programing
Ruby on Rails 3.1: Let's bring the fun back into web programingRuby on Rails 3.1: Let's bring the fun back into web programing
Ruby on Rails 3.1: Let's bring the fun back into web programing
 
Charla EHU Noviembre 2014 - Desarrollo Web
Charla EHU Noviembre 2014 - Desarrollo WebCharla EHU Noviembre 2014 - Desarrollo Web
Charla EHU Noviembre 2014 - Desarrollo Web
 
Connecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRubyConnecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRuby
 
Practical Testing of Ruby Core
Practical Testing of Ruby CorePractical Testing of Ruby Core
Practical Testing of Ruby Core
 
Socket applications
Socket applicationsSocket applications
Socket applications
 
Your own (little) gem: building an online business with Ruby
Your own (little) gem: building an online business with RubyYour own (little) gem: building an online business with Ruby
Your own (little) gem: building an online business with Ruby
 
Minicurso Ruby e Rails
Minicurso Ruby e RailsMinicurso Ruby e Rails
Minicurso Ruby e Rails
 
Play vs Rails
Play vs RailsPlay vs Rails
Play vs Rails
 
Debugging of (C)Python applications
Debugging of (C)Python applicationsDebugging of (C)Python applications
Debugging of (C)Python applications
 
Hiveminder - Everything but the Secret Sauce
Hiveminder - Everything but the Secret SauceHiveminder - Everything but the Secret Sauce
Hiveminder - Everything but the Secret Sauce
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with Clojure
 
How to Begin Developing Ruby Core
How to Begin Developing Ruby CoreHow to Begin Developing Ruby Core
How to Begin Developing Ruby Core
 
Distributed, Incremental Dataflow Processing on AWS with GRAIL's Reflow (CMP3...
Distributed, Incremental Dataflow Processing on AWS with GRAIL's Reflow (CMP3...Distributed, Incremental Dataflow Processing on AWS with GRAIL's Reflow (CMP3...
Distributed, Incremental Dataflow Processing on AWS with GRAIL's Reflow (CMP3...
 
Crossing the Bridge: Connecting Rails and your Front-end Framework
Crossing the Bridge: Connecting Rails and your Front-end FrameworkCrossing the Bridge: Connecting Rails and your Front-end Framework
Crossing the Bridge: Connecting Rails and your Front-end Framework
 

More from kwatch

How to make the fastest Router in Python
How to make the fastest Router in PythonHow to make the fastest Router in Python
How to make the fastest Router in Python
kwatch
 
Migr8.rb チュートリアル
Migr8.rb チュートリアルMigr8.rb チュートリアル
Migr8.rb チュートリアル
kwatch
 
なんでもID
なんでもIDなんでもID
なんでもID
kwatch
 
Nippondanji氏に怒られても仕方ない、配列型とJSON型の使い方
Nippondanji氏に怒られても仕方ない、配列型とJSON型の使い方Nippondanji氏に怒られても仕方ない、配列型とJSON型の使い方
Nippondanji氏に怒られても仕方ない、配列型とJSON型の使い方
kwatch
 
【SQLインジェクション対策】徳丸先生に怒られない、動的SQLの安全な組み立て方
【SQLインジェクション対策】徳丸先生に怒られない、動的SQLの安全な組み立て方【SQLインジェクション対策】徳丸先生に怒られない、動的SQLの安全な組み立て方
【SQLインジェクション対策】徳丸先生に怒られない、動的SQLの安全な組み立て方
kwatch
 
O/Rマッパーによるトラブルを未然に防ぐ
O/Rマッパーによるトラブルを未然に防ぐO/Rマッパーによるトラブルを未然に防ぐ
O/Rマッパーによるトラブルを未然に防ぐ
kwatch
 
正規表現リテラルは本当に必要なのか?
正規表現リテラルは本当に必要なのか?正規表現リテラルは本当に必要なのか?
正規表現リテラルは本当に必要なのか?
kwatch
 
【公開終了】Python4PHPer - PHPユーザのためのPython入門 (Python2.5)
【公開終了】Python4PHPer - PHPユーザのためのPython入門 (Python2.5)【公開終了】Python4PHPer - PHPユーザのためのPython入門 (Python2.5)
【公開終了】Python4PHPer - PHPユーザのためのPython入門 (Python2.5)
kwatch
 
DBスキーマもバージョン管理したい!
DBスキーマもバージョン管理したい!DBスキーマもバージョン管理したい!
DBスキーマもバージョン管理したい!
kwatch
 
PHPとJavaScriptにおけるオブジェクト指向を比較する
PHPとJavaScriptにおけるオブジェクト指向を比較するPHPとJavaScriptにおけるオブジェクト指向を比較する
PHPとJavaScriptにおけるオブジェクト指向を比較する
kwatch
 
SQL上級者こそ知って欲しい、なぜO/Rマッパーが重要か?
SQL上級者こそ知って欲しい、なぜO/Rマッパーが重要か?SQL上級者こそ知って欲しい、なぜO/Rマッパーが重要か?
SQL上級者こそ知って欲しい、なぜO/Rマッパーが重要か?
kwatch
 
Fantastic DSL in Python
Fantastic DSL in PythonFantastic DSL in Python
Fantastic DSL in Python
kwatch
 
What is wrong on Test::More? / Test::Moreが抱える問題点とその解決策
What is wrong on Test::More? / Test::Moreが抱える問題点とその解決策What is wrong on Test::More? / Test::Moreが抱える問題点とその解決策
What is wrong on Test::More? / Test::Moreが抱える問題点とその解決策
kwatch
 
PHP5.5新機能「ジェネレータ」初心者入門
PHP5.5新機能「ジェネレータ」初心者入門PHP5.5新機能「ジェネレータ」初心者入門
PHP5.5新機能「ジェネレータ」初心者入門
kwatch
 
Pretty Good Branch Strategy for Git/Mercurial
Pretty Good Branch Strategy for Git/MercurialPretty Good Branch Strategy for Git/Mercurial
Pretty Good Branch Strategy for Git/Mercurial
kwatch
 
Oktest - a new style testing library for Python -
Oktest - a new style testing library for Python -Oktest - a new style testing library for Python -
Oktest - a new style testing library for Python -
kwatch
 
文字列結合のベンチマークをいろんな処理系でやってみた
文字列結合のベンチマークをいろんな処理系でやってみた文字列結合のベンチマークをいろんな処理系でやってみた
文字列結合のベンチマークをいろんな処理系でやってみた
kwatch
 
I have something to say about the buzz word "From Java to Ruby"
I have something to say about the buzz word "From Java to Ruby"I have something to say about the buzz word "From Java to Ruby"
I have something to say about the buzz word "From Java to Ruby"kwatch
 
Javaより速いLL用テンプレートエンジン
Javaより速いLL用テンプレートエンジンJavaより速いLL用テンプレートエンジン
Javaより速いLL用テンプレートエンジン
kwatch
 
Underlaying Technology of Modern O/R Mapper
Underlaying Technology of Modern O/R MapperUnderlaying Technology of Modern O/R Mapper
Underlaying Technology of Modern O/R Mapper
kwatch
 

More from kwatch (20)

How to make the fastest Router in Python
How to make the fastest Router in PythonHow to make the fastest Router in Python
How to make the fastest Router in Python
 
Migr8.rb チュートリアル
Migr8.rb チュートリアルMigr8.rb チュートリアル
Migr8.rb チュートリアル
 
なんでもID
なんでもIDなんでもID
なんでもID
 
Nippondanji氏に怒られても仕方ない、配列型とJSON型の使い方
Nippondanji氏に怒られても仕方ない、配列型とJSON型の使い方Nippondanji氏に怒られても仕方ない、配列型とJSON型の使い方
Nippondanji氏に怒られても仕方ない、配列型とJSON型の使い方
 
【SQLインジェクション対策】徳丸先生に怒られない、動的SQLの安全な組み立て方
【SQLインジェクション対策】徳丸先生に怒られない、動的SQLの安全な組み立て方【SQLインジェクション対策】徳丸先生に怒られない、動的SQLの安全な組み立て方
【SQLインジェクション対策】徳丸先生に怒られない、動的SQLの安全な組み立て方
 
O/Rマッパーによるトラブルを未然に防ぐ
O/Rマッパーによるトラブルを未然に防ぐO/Rマッパーによるトラブルを未然に防ぐ
O/Rマッパーによるトラブルを未然に防ぐ
 
正規表現リテラルは本当に必要なのか?
正規表現リテラルは本当に必要なのか?正規表現リテラルは本当に必要なのか?
正規表現リテラルは本当に必要なのか?
 
【公開終了】Python4PHPer - PHPユーザのためのPython入門 (Python2.5)
【公開終了】Python4PHPer - PHPユーザのためのPython入門 (Python2.5)【公開終了】Python4PHPer - PHPユーザのためのPython入門 (Python2.5)
【公開終了】Python4PHPer - PHPユーザのためのPython入門 (Python2.5)
 
DBスキーマもバージョン管理したい!
DBスキーマもバージョン管理したい!DBスキーマもバージョン管理したい!
DBスキーマもバージョン管理したい!
 
PHPとJavaScriptにおけるオブジェクト指向を比較する
PHPとJavaScriptにおけるオブジェクト指向を比較するPHPとJavaScriptにおけるオブジェクト指向を比較する
PHPとJavaScriptにおけるオブジェクト指向を比較する
 
SQL上級者こそ知って欲しい、なぜO/Rマッパーが重要か?
SQL上級者こそ知って欲しい、なぜO/Rマッパーが重要か?SQL上級者こそ知って欲しい、なぜO/Rマッパーが重要か?
SQL上級者こそ知って欲しい、なぜO/Rマッパーが重要か?
 
Fantastic DSL in Python
Fantastic DSL in PythonFantastic DSL in Python
Fantastic DSL in Python
 
What is wrong on Test::More? / Test::Moreが抱える問題点とその解決策
What is wrong on Test::More? / Test::Moreが抱える問題点とその解決策What is wrong on Test::More? / Test::Moreが抱える問題点とその解決策
What is wrong on Test::More? / Test::Moreが抱える問題点とその解決策
 
PHP5.5新機能「ジェネレータ」初心者入門
PHP5.5新機能「ジェネレータ」初心者入門PHP5.5新機能「ジェネレータ」初心者入門
PHP5.5新機能「ジェネレータ」初心者入門
 
Pretty Good Branch Strategy for Git/Mercurial
Pretty Good Branch Strategy for Git/MercurialPretty Good Branch Strategy for Git/Mercurial
Pretty Good Branch Strategy for Git/Mercurial
 
Oktest - a new style testing library for Python -
Oktest - a new style testing library for Python -Oktest - a new style testing library for Python -
Oktest - a new style testing library for Python -
 
文字列結合のベンチマークをいろんな処理系でやってみた
文字列結合のベンチマークをいろんな処理系でやってみた文字列結合のベンチマークをいろんな処理系でやってみた
文字列結合のベンチマークをいろんな処理系でやってみた
 
I have something to say about the buzz word "From Java to Ruby"
I have something to say about the buzz word "From Java to Ruby"I have something to say about the buzz word "From Java to Ruby"
I have something to say about the buzz word "From Java to Ruby"
 
Javaより速いLL用テンプレートエンジン
Javaより速いLL用テンプレートエンジンJavaより速いLL用テンプレートエンジン
Javaより速いLL用テンプレートエンジン
 
Underlaying Technology of Modern O/R Mapper
Underlaying Technology of Modern O/R MapperUnderlaying Technology of Modern O/R Mapper
Underlaying Technology of Modern O/R Mapper
 

Recently uploaded

AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 

Recently uploaded (20)

AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 

Erubis徹底解説

  • 1. RubyKaigi2009 Erubis makoto kuwata <kwa@kuwata-lab.com> http://www.kuwata-lab.com/ copyright(c) 2009 kuwata-lab.com all rights reserved. 1
  • 2. ‣ ‣ copyright(c) 2009 kuwata-lab.com all rights reserved. 2
  • 3. Agenda ‣ Part 1. Erubis ‣ Part 2. eRuby ‣ Part 3. copyright(c) 2009 kuwata-lab.com all rights reserved. 3
  • 4. Part 1. Erubis copyright(c) 2009 kuwata-lab.com all rights reserved. 4
  • 5. Erubis ‣ pure Ruby eRuby ‣ • http://jp.rubyist.net/magazine/?0022-FasterThanC ‣ • HTML • • PHP, Java, JS, C, Perl, Scheme • ... copyright(c) 2009 kuwata-lab.com all rights reserved. 5
  • 6. Ruby program: require 'rubygems' # require 'erubis' str = File.read('template.eruby') eruby = Erubis::Eruby.new(str) print eruby.result(binding()) command-line: $ erubis template.eruby # $ erubis -x template.eruby # Ruby $ erubis -z template.eruby # copyright(c) 2009 kuwata-lab.com all rights reserved. 6
  • 7. HTML str =<<END <%= %> <%= var %> <%== %> <%== var %> END eruby = Erubis::Eruby.new(str, :escape=>true) puts eruby.result(:var=>"<B&B>") output: &lt;B&am;&gt; <B&B> (choosability) copyright(c) 2009 kuwata-lab.com all rights reserved. 7
  • 8. <% %> [% %] [% for x in @list %] <li>[%= x %]</li> [% end %] ! ## Ruby Erubis::Eruby.new(str, :pattern=>'[% %]') ## command-line $ erubis -p '[% %]' file.eruby copyright(c) 2009 kuwata-lab.com all rights reserved. 8
  • 9. Binding Hash Object Hash Object hash = { @title = "Example" :title => "Example", @items = [1, 2, 3] :items => [1, 2, 3], } erubis = erubis = Erubis::Eruby.new(str) Erubis::Eruby.new(str) puts erubis.evaluate(self) puts erubis.result(hash) <h1><%= title%></h1> <h1><%= @title%></h1> <% for x in items %> <% for x in @items %> <% end %> <% end %> copyright(c) 2009 kuwata-lab.com all rights reserved. 9
  • 10. Enhancer ‣ Erubis module ## <%= %> HTML module EscapeEnhancer def add_expr(src, code, indicator) if indicator == '=' src << " _buf<<escapeXml(#{code})" elsif indicator == '==' src << " _buf<<(#{code}).to_s;" end end Erubis end copyright(c) 2009 kuwata-lab.com all rights reserved. 10
  • 11. Enhancer (cont') ### Enhancer ### ( : print() ) module StdoutEnhancer _buf="" def add_preamble(src) _buf=$stdout src << "_buf = $stdout;" end def add_postamble(src) src << "n""n" end _buf.to_s end "" ( ) copyright(c) 2009 kuwata-lab.com all rights reserved. 11
  • 12. Enhancer include/extend ### Ruby class MyEruby < Erubis::Eruby include Erubis::EscapeEnhancer include Erubis::PercentLineEnhancer end puts MyEruby.new(str).result(:items=>[1,2,3]) , ### command-line $ erubis -E Escape,Percent file.eruby copyright(c) 2009 kuwata-lab.com all rights reserved. 12
  • 13. Enhancer ‣ EscapeEnhancer : HTML ‣ PercentLineEnhancer : '%' ‣ InterporationEnhancer : _buf<<"#{ }" ‣ DeleteIndentEnhancer : HTML ‣ StdoutEnhancer : _buf="" _buf=$stdout ‣ ... (erubis -h ) copyright(c) 2009 kuwata-lab.com all rights reserved. 13
  • 14. ( ) ### command-line $ erubis -c '{arr: [A, B, C]}' template.eruby # YAML $ erubis -c '@arr=%w[A B C]' template.eruby # Ruby <% for x in @arr %> <li>A</li> <li><%= x %></li> <li>B</li> <% end %> <li>C</li> copyright(c) 2009 kuwata-lab.com all rights reserved. 14
  • 15. *.yaml *.rb $ erubis -f data.yaml template.eruby # YAML $ erubis -f data.rb template.eruby # Ruby data.yaml data.rb title: Example @title = "Example" items: @items = - name: Foo [ {"name"=>"Foo"}, - name: Bar {"name"=>"Bar"}, ] copyright(c) 2009 kuwata-lab.com all rights reserved. 15
  • 16. ‣ <%=== %> <%=== @var %> 2 ### Ruby $stderr.puts("*** debug: @var=#{@var.inspect}") ### *** debug: @var=["A", "B", "C"] copyright(c) 2009 kuwata-lab.com all rights reserved. 16
  • 17. ‣ PHP, Java, JS, C, Perl,Scheme ( ) <% for (i=0; i<n; i++) { %> (C ) <li><%= "%d", i %> printf() <% } %> #line 1 "file.ec" (erubis -xl c file.ec ) for (i=0; i<n; i++) { fputs("<li>", stdout); fprintf(stdout, "%d", i); fputs("n", stdout); } copyright(c) 2009 kuwata-lab.com all rights reserved. 17
  • 18. ‣ Erubis • HTML • • Enhancer • / • • PHP, Java, JS, C, Perl, Scheme copyright(c) 2009 kuwata-lab.com all rights reserved. 18
  • 19. Part 2. eRuby copyright(c) 2009 kuwata-lab.com all rights reserved. 19
  • 20. ‣ binding() • i=0 ### file.erb str = File.read('file.erb') <% for i in 1..3 %> ERB.new(str).result(binding) <li><%= i %></li> p i #=> 3 <% end %> ! copyright(c) 2009 kuwata-lab.com all rights reserved. 20
  • 21. ‣ binding() • • b = Bingind.new b[:title] = "Example" … b[:items] = [1, 2, 3] copyright(c) 2009 kuwata-lab.com all rights reserved. 21
  • 22. ERB ‣( ) ‣ Struct • http://d.hatena.ne.jp/m_seki/20080528/1211909590 Foo = Struct.new(:title, :items) class Foo def env; binding(); end end ctx = Foo.new("Example", [1,2,3]) ERB.new(str).result(ctx.env) copyright(c) 2009 kuwata-lab.com all rights reserved. 22
  • 23. Erubis ‣ Binding Hash erubis.result(:items=>[1, 2, 3]) def result(b=TOPLEVEL_BINDING) if b.is_a?(Hash) s = b.collect{|k,v| "#{k}=b[#{k.inspect}];"}.join b = binding() eval s, b Binding end return eval(@src, b) end copyright(c) 2009 kuwata-lab.com all rights reserved. 23
  • 24. Erubis ‣ Binding Object @items = [1, 2, 3]; <% for x in @items %> erubis.evaluate(self) <% end %> def evaluate(ctx) Hash if ctx.is_a?(Hash) hash = ctx; ctx = Object.new hash.each {|k,v| ctx.instance_variable_set("@#{k}", v) } end return ctx.instance_eval(@src) end copyright(c) 2009 kuwata-lab.com all rights reserved. 24
  • 25. ERB 1. 8.6 Erubis::Eruby ERB 1. 8.7 Erubis::Eruby ERB 1.9.1 Erubis::Eruby 0 10 20 30 (sec) (by eval) (eRuby→Ruby) copyright(c) 2009 kuwata-lab.com all rights reserved. 25
  • 26. ERB ‣ ‣ • class Foo extend ERB::DefMethod def_erb_method('render', 'template.erb') end print Foo.new.render copyright(c) 2009 kuwata-lab.com all rights reserved. 26
  • 27. Erubis ‣ • Ruby *.cache •2 *.cache eruby = Erubis::Eruby.load_file("file.eruby") print eruby.result() CGI copyright(c) 2009 kuwata-lab.com all rights reserved. 27
  • 28. Erubis ‣ Proc • • instance_eval def evaluate(ctx) Proc @proc ||= eval(@src) ctx.instance_eval(@proc) end copyright(c) 2009 kuwata-lab.com all rights reserved. 28
  • 29. • HTML <ul> <ul> <% for x in @list %> <li>AAA</li> <li><%= x %></li> <% end %> <li>BBB</li> </ul> </ul> copyright(c) 2009 kuwata-lab.com all rights reserved. 29
  • 30. ERB ‣ trim mode • ">" : "%>" • "<>" : "<%" "%>" • "-" : "<%-" "-%>" • "%" : "%" • "%>", "%<>", "-" : "%" ">"/"<>"/"-" ERB.new(str, nil, "%<>") copyright(c) 2009 kuwata-lab.com all rights reserved. 30
  • 31. Erubis ‣ • <% %> • <%= %> <ul> <ul> <% for x in @list %> AAA <%= x %> BBB <% end %> CCC </ul> </ul> copyright(c) 2009 kuwata-lab.com all rights reserved. 31
  • 32. ERB Erubis eRuby × ( ) ( ) × ( ) ( ) × ( ) ( ) copyright(c) 2009 kuwata-lab.com all rights reserved. 32
  • 33. • [ruby-list:18894] eRuby (?) ‣ • <% %> <%= %> • copyright(c) 2009 kuwata-lab.com all rights reserved. 33
  • 34. <%= %> HTML ! • eRuby HTML • ‣ ? copyright(c) 2009 kuwata-lab.com all rights reserved. 34
  • 35. ERB ‣( ) ‣ • String • http://www2a.biglobe.ne.jp/~seki/ruby/erbquote.html copyright(c) 2009 kuwata-lab.com all rights reserved. 35
  • 36. Erubis ‣ Erubis • eruby = Erubis::Eruby.new(str, :escape=>true) # or eruby = Erubis::EscapedEruby.new(str) puts eruby.evaluate(ctx) Hi <%= @name %>! # Hi <%== @name %>! # copyright(c) 2009 kuwata-lab.com all rights reserved. 36
  • 37. <% unless @items.blank? %> <table> <tbody> <% @items.each do |item| %> <tr class="item" id="item-<%=item.id%>"> <td class="item-id"><%= item.id %></td> <td class="item-name"> <% if item.url && !item.url.empty? %> <a href="<%= item.url %>"><%=item.name%></a> <% else %> <span><%=item.name%></span> <% end %> </td> </tr> HTML Ruby <% end %> </tbody> end </table> (do end 100 ) <% end %> copyright(c) 2009 kuwata-lab.com all rights reserved. 37
  • 38. ERB ‣ ( erb -x ) $ erb -x foo.eruby _erbout = ''; unless @items.blank? ; _erbout.concat "n" _erbout.concat "<table>n" _erbout.concat " <tr class="record">n" $ erb -x foo.eruby | ruby -wc Syntax OK copyright(c) 2009 kuwata-lab.com all rights reserved. 38
  • 39. Erubis ‣ • -x : Ruby • -X : HTML • -N : (number) • -U : 1 (unique) • -C : (compact) • -z : copyright(c) 2009 kuwata-lab.com all rights reserved. 39
  • 40. $ cat foo.eruby <% unless @items.blank? %> <table> <% @items.each_with_index do|x, i| %> <tr class="record"> <td><%= i +1 %></td> <td><%=h x %></td> </tr> <% end %> </table> <% end %> copyright(c) 2009 kuwata-lab.com all rights reserved. 40
  • 41. -x Ruby $ erubis -x foo.eruby _buf = ''; unless @items.blank? _buf << '<table> '; @items.each_with_index do|x, i| _buf << ' <tr class="record"> <td>'; _buf << ( i +1 ).to_s; _buf << '</td> <td>'; _buf << (h x ).to_s; _buf << '</td> </tr> '; end _buf << '</table> '; end _buf.to_s copyright(c) 2009 kuwata-lab.com all rights reserved. 41
  • 42. -X $ erubis -X foo.eruby _buf = ''; unless @items.blank? @items.each_with_index do|x, i| _buf << ( i +1 ).to_s; _buf << (h x ).to_s; end end _buf.to_s copyright(c) 2009 kuwata-lab.com all rights reserved. 42
  • 43. -N (number) $ erubis -XN foo.eruby 1: _buf = ''; unless @items.blank? 2: 3: @items.each_with_index do|x, i| 4: 5: _buf << ( i +1 ).to_s; 6: _buf << (h x ).to_s; 7: 8: end 9: 10: end 11: _buf.to_s copyright(c) 2009 kuwata-lab.com all rights reserved. 43
  • 44. -U (uniq) $ erubis -XNU foo.eruby 1: _buf = ''; unless @items.blank? 3: @items.each_with_index do|x, i| 5: _buf << ( i +1 ).to_s; 6: _buf << (h x ).to_s; 8: end 10: end 11: _buf.to_s copyright(c) 2009 kuwata-lab.com all rights reserved. 44
  • 45. -C (compact) $ erubis -XNC foo.eruby 1: _buf = ''; unless @items.blank? 3: @items.each_with_index do|x, i| 5: _buf << ( i +1 ).to_s; 6: _buf << (h x ).to_s; 8: end 10: end 11: _buf.to_s copyright(c) 2009 kuwata-lab.com all rights reserved. 45
  • 46. <%= %> <%= form_for :user do %> <div> <%= text_field :name %> </div> <% end %> eRuby copyright(c) 2009 kuwata-lab.com all rights reserved. 46
  • 47. <%= %> <%= 10.times do %> Hello <% end %> ! _buf = ""; _buf << ( 10.times do ).to_s; _buf << " Hellon"; end copyright(c) 2009 kuwata-lab.com all rights reserved. 47
  • 48. ERB+Rails ‣ (_erbout) ! form_for() … _erbout <% form_for do %> _erbout = "" Hello form_for do <% end %> _erbout.concat("Hello") end copyright(c) 2009 kuwata-lab.com all rights reserved. 48
  • 49. Erubis+Merb ‣ Erubis <%= form_for do %> @_buf << (form_for do; Hello @_buf << "Hellon" <% end =%> end); copyright(c) 2009 kuwata-lab.com all rights reserved. 49
  • 50. ‣ eRuby ‣ (kool!) ‣ • @_buf ‣ copyright(c) 2009 kuwata-lab.com all rights reserved. 50
  • 51. ‣ eRuby eRuby • • • • • HTML • • copyright(c) 2009 kuwata-lab.com all rights reserved. 51
  • 52. Part 3. copyright(c) 2009 kuwata-lab.com all rights reserved. 52
  • 53. ‣ <ul> print "<ul>n" <% for x in @a %> for x in @a <li><%=x%></li> print "<li>#{x}</li>n" <% end %> end </ul> print "</u>n" copyright(c) 2009 kuwata-lab.com all rights reserved. 53
  • 54. <ul> s = File.read('foo.eruby') <li><%=x%></li> e = Erubis::Eruby.new(s) </ul> puts e.evaluate(:x=>1) copyright(c) 2009 kuwata-lab.com all rights reserved. 54
  • 55. ? <%#ARGS: items, name='guest' %> Hello <%= name %>! <% for x in items %> <li><%=x%></li> <% end %> copyright(c) 2009 kuwata-lab.com all rights reserved. 55
  • 56. ‣ HTML • <html> <html> <body> <body> !( ) </body> <h1><%=@title%></h1> </html> <ul id="menulist"> <% for x in @items %> <h1><%=@title%></h1> <li><%=x%></li> <ul id="menulist"> </ul> <% end %> </ul> <% for x in @items %> </body> <li><%= x %></li> </html> <% end %> copyright(c) 2009 kuwata-lab.com all rights reserved. 56
  • 57. ‣ Django .... {% block pagetitle %} <h1>{{title}}</h1> {% endblock %} .... (method override) copyright(c) 2009 kuwata-lab.com all rights reserved. 57
  • 58. AOP ‣ AOP : Aspect Oriented Programming • / <table> "for x in @a" •HTML <tr> <td> "print x" </tr> • "end" </table> ( ) copyright(c) 2009 kuwata-lab.com all rights reserved. 58
  • 59. ‣ HTML View • … ‣ HTML String (http://www.oiwa.jp/~yutaka/tdiary/20051229.html) • / • Python str unicode • HTML+String • HTML (SQL ) copyright(c) 2009 kuwata-lab.com all rights reserved. 59
  • 60. ‣ ‣ • AOP … ‣ copyright(c) 2009 kuwata-lab.com all rights reserved. 60
  • 61. • http://jp.rubyist.net/magazine/?0024-TemplateSystem ‣ • http://jp.rubyist.net/magazine/?0024-TemplateSystem2 ‣ Erubis • http://www.kuwata-lab.com/erubis/ ‣ • http://www.kuwata-lab.com/tenjin/ copyright(c) 2009 kuwata-lab.com all rights reserved. 61
  • 62. one more thing copyright(c) 2009 kuwata-lab.com all rights reserved. 62
  • 63. Tenjin - template engine replacing eRuby ‣ ERB Erubis • eRuby • ‣ Tenjin : • / • - ... • http://www.kuwata-lab.com/tenjin/ copyright(c) 2009 kuwata-lab.com all rights reserved. 63
  • 64. thank you copyright(c) 2009 kuwata-lab.com all rights reserved. 64