Module: Wesc
- Defined in:
- lib/wesc.rb,
lib/wesc/version.rb
Constant Summary collapse
- VERSION =
"0.6.2"
Class Method Summary collapse
-
.build(entry_points, outcss: nil, outjs: nil, minify: false) ⇒ String
Build the entry points and return the full HTML output as a (binary) String.
-
.build_stream(entry_points, outcss: nil, outjs: nil, minify: false) {|chunk| ... } ⇒ void
Stream the build to a block, chunk by chunk, for low-memory output.
Class Method Details
.build(entry_points, outcss: nil, outjs: nil, minify: false) ⇒ String
Build the entry points and return the full HTML output as a (binary) String.
html = Wesc.build(["./index.html"], minify: true)
38 39 40 |
# File 'lib/wesc.rb', line 38 def build(entry_points, outcss: nil, outjs: nil, minify: false) Native.build(Array(entry_points), outcss, outjs, minify ? true : false) end |
.build_stream(entry_points, outcss: nil, outjs: nil, minify: false) {|chunk| ... } ⇒ void
This method returns an undefined value.
Stream the build to a block, chunk by chunk, for low-memory output.
The block is called with each chunk as a String, then once with ‘nil` to signal the end of the stream. Raising from the block stops the build and the exception propagates out of this method.
Wesc.build_stream(["./index.html"]) do |chunk|
io.write(chunk) unless chunk.nil?
end
59 60 61 62 63 |
# File 'lib/wesc.rb', line 59 def build_stream(entry_points, outcss: nil, outjs: nil, minify: false, &block) raise ArgumentError, "Wesc.build_stream requires a block" unless block Native.build_stream(Array(entry_points), outcss, outjs, minify ? true : false, &block) end |