るりまサーチ

最速Rubyリファレンスマニュアル検索!
60件ヒット [1-60件を表示] (0.021秒)
トップページ > クエリ:test[x] > クラス:ERB[x]

別のキーワード

  1. kernel test
  2. _builtin test
  3. rubygems/test_utilities tempio
  4. rubygems/test_utilities fetcher=
  5. validator unit_test

ライブラリ

キーワード

検索結果

ERB#result(b=TOPLEVEL_BINDING) -> String (43.0)

ERB を b の binding で実行し、結果の文字列を返します。

...
ERB
を b の binding で実行し、結果の文字列を返します。

@param b eRubyスクリプトが実行されるときのbinding

//emlist[例][ruby]{
require 'erb'
erb
= ERB.new("test <%= test1 %>\ntest <%= test2 %>\n")
test
1 = "foo"
test
2 = "bar"
puts erb.result
# test foo
# test bar
//...
...}

@see ERB#result_with_hash...

ERB#run(b=TOPLEVEL_BINDING) -> nil (43.0)

ERB を b の binding で実行し、結果を標準出力へ印字します。

...
ERB
を b の binding で実行し、結果を標準出力へ印字します。

@param b eRubyスクリプトが実行されるときのbinding

//emlist[例][ruby]{
require 'erb'
erb
= ERB.new("test <%= test1 %>\ntest <%= test2 %>\n")
test
1 = "foo"
test
2 = "bar"
erb
.run
# test foo
# test bar
//}...

ERB#def_module(methodname=&#39;erb&#39;) -> Module (19.0)

変換した Ruby スクリプトをメソッドとして定義した無名のモジュールを返します。

...ッド名

//emlist[例][ruby]{
require 'erb'
filename = 'example.rhtml'
erb
= ERB.new("test1<%= arg1 %>\ntest2<%= arg2 %>\n")
erb
.filename = filename
MyModule = erb.def_module('render(arg1, arg2)')
class MyClass
include MyModule
end
print MyClass.new.render('foo', 123)
# test1foo
# test2123
//}...

ERB#def_class(superklass=Object, methodname=&#39;erb&#39;) -> Class (13.0)

変換した Ruby スクリプトをメソッドとして定義した無名のクラスを返します。

...mlist[例][ruby]{
require 'erb'

class MyClass_
def initialize(arg1, arg2)
@arg1 = arg1; @arg2 = arg2
end
end
filename = 'example.rhtml' # @arg1 と @arg2 が使われている example.rhtml

erb
= ERB.new(File.read(filename))
erb
.filename = filename
MyClass = erb.def_class(MyClass_, 'rend...
...er()')
print MyClass.new('foo', 123).render()

# => test1foo
# test2123
//}...

ERB#src -> String (13.0)

変換した Ruby スクリプトを取得します。

...

//emlist[例][ruby]{
require 'erb'
erb
= ERB.new("test1<%= @arg1%>\ntest2<%= @arg2%>\n\n")
puts erb.src

# #coding:UTF-8
# _erbout = +''; _erbout.<< "test1".freeze; _erbout.<<(( @arg1).to_s); _erbout.<< "\ntest2".freeze
# ; _erbout.<<(( @arg2).to_s); _erbout.<< "\n\n".freeze
#
# ; _erbout
//}...

絞り込み条件を変える