Module: Pug
- Defined in:
- lib/pug-rails.rb,
lib/pug/railtie.rb,
lib/pug/version.rb,
lib/pug/template.rb
Defined Under Namespace
Classes: CompileError, Railtie, Template
Constant Summary
collapse
- VERSION =
'1.11.0.1'
Class Method Summary
collapse
Class Method Details
.compile(source, options = {}) ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/pug-rails.rb', line 8
def compile(source, options = {})
source = source.read if source.respond_to?(:read)
cmd = [ options.fetch(:executable) ]
cmd.push('--client')
cmd.push('--path', options[:filename]) if options[:filename]
cmd.push('--pretty') if options[:pretty]
cmd.push('--no-debug') unless options[:debug]
cmd.push('--obj', JSON.generate(options))
stdout, stderr, exit_status = Open3.capture3(*cmd, stdin_data: source)
raise CompileError.new(stderr) unless exit_status.success?
stdout
end
|
.find_executable ⇒ Object
26
27
28
29
30
31
|
# File 'lib/pug-rails.rb', line 26
def find_executable
%w( pug jade ).find do |name|
`which #{name}`
$?.success?
end
end
|