Wrong documentation about erb -P?

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?

On 11/22/2013 02:34 AM, David P. wrote:

; _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?

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:
https://github.com/ruby/ruby/commit/4de16dfb245db76d3192ed57a38c50635d8b7015

So just a documentation issue in the man page which has also been there
forever. File a bug?

-Justin

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs