Sha256: 37a3b9053a35b9303fed4d96fc0c374ea28440230ce09fb7b5ef4691f4e31571
Contents?: true
Size: 1.13 KB
Versions: 1
Compression:
Stored size: 1.13 KB
Contents
# frozen_string_literal: true module Slim # In Slim you don't need the do keyword sometimes. This # filter adds the missing keyword. # # - 10.times # | Hello # # @api private class DoInserter < Filter BLOCK_REGEX = /(\A(if|unless|else|elsif|when|in|begin|rescue|ensure|case)\b)|\bdo\s*(\|[^\|]*\|\s*)?\Z/ # Handle control expression `[:slim, :control, code, content]` # # @param [String] code Ruby code # @param [Array] content Temple expression # @return [Array] Compiled temple expression def on_slim_control(code, content) code = code + ' do' unless code =~ BLOCK_REGEX || empty_exp?(content) [:slim, :control, code, compile(content)] end # Handle output expression `[:slim, :output, escape, code, content]` # # @param [Boolean] escape Escape html # @param [String] code Ruby code # @param [Array] content Temple expression # @return [Array] Compiled temple expression def on_slim_output(escape, code, content) code = code + ' do' unless code =~ BLOCK_REGEX || empty_exp?(content) [:slim, :output, escape, code, compile(content)] end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
slim-5.1.1 | lib/slim/do_inserter.rb |