7stud2
(7stud --)
22 November 2013 10:34
1
according to "man erb", the -P options: Evaluates lines starting with %
as Ruby code and removes the tailing EOLs.
However, it seems to be the opposite: by default, erb evaluates lines
starting with % as Ruby code;
and by specifying the -P option, erb does.
$ echo "hello" | erb -x --
#coding:ASCII-8BIT
_erbout = ''; _erbout.concat "hello\n"
; _erbout.force_encoding(__ENCODING__)
$ echo "%hello" | erb -x --
#coding:ASCII-8BIT
_erbout = ''; hello <<<< ruby code
_erbout.force_encoding(__ENCODING__)
$ echo "hello" | erb -P -x --
#coding:ASCII-8BIT
_erbout = ''; _erbout.concat "hello\n"
; _erbout.force_encoding(__ENCODING__)
$ echo "%hello" | erb -P -x --
#coding:ASCII-8BIT
_erbout = ''; _erbout.concat "%hello\n" <<<< no ruby code
; _erbout.force_encoding(__ENCODING__)
is it a bug in the "man erb" documentation,
or I am misunderstanding it?
···
--
Posted via http://www.ruby-forum.com/ .
Looks like the man page for erb is just wrong:
$ erb --help
print this help
erb [switches] [inputfile]
-x print ruby script
-n print ruby script with line number
-v enable verbose mode
-d set $DEBUG to true
-r library load a library
-S safe_level set $SAFE (0..4)
-E ex[:in] set default external/internal encodings
-U set default encoding to UTF-8.
-T trim_mode specify trim_mode (0..2, -)
-P ignore lines which start with "%"
erb (the commandline tool) has always defaulted to interpreting lines beginning with % as Ruby code: add bin/erb · ruby/ruby@4de16df · GitHub
So just a documentation issue in the man page which has also been there forever. File a bug?
-Justin
···
On 11/22/2013 02:34 AM, David P. wrote:
according to "man erb", the -P options: Evaluates lines starting with %
as Ruby code and removes the tailing EOLs.
However, it seems to be the opposite: by default, erb evaluates lines
starting with % as Ruby code;
and by specifying the -P option, erb does.
$ echo "hello" | erb -x --
#coding:ASCII-8BIT
_erbout = ''; _erbout.concat "hello\n"
; _erbout.force_encoding(__ENCODING__)
$ echo "%hello" | erb -x --
#coding:ASCII-8BIT
_erbout = ''; hello <<<< ruby code
_erbout.force_encoding(__ENCODING__)
$ echo "hello" | erb -P -x --
#coding:ASCII-8BIT
_erbout = ''; _erbout.concat "hello\n"
; _erbout.force_encoding(__ENCODING__)
$ echo "%hello" | erb -P -x --
#coding:ASCII-8BIT
_erbout = ''; _erbout.concat "%hello\n" <<<< no ruby code
; _erbout.force_encoding(__ENCODING__)
is it a bug in the "man erb" documentation,
or I am misunderstanding it?