Sha256: ae09f9844f204b0a437d8c3c516ce671a05ec4c481e19509d401bab97e1b08e0

Contents?: true

Size: 762 Bytes

Versions: 18

Compression:

Stored size: 762 Bytes

Contents

module Hamlit
  class Filters
    class Javascript < TextBase
      def compile(node)
        case @format
        when :xhtml
          compile_xhtml(node)
        else
          compile_html(node)
        end
      end

      private

      def compile_html(node)
        temple = [:multi]
        temple << [:static, "<script>\n".freeze]
        compile_text!(temple, node, '  '.freeze)
        temple << [:static, "\n</script>".freeze]
        temple
      end

      def compile_xhtml(node)
        temple = [:multi]
        temple << [:static, "<script type='text/javascript'>\n  //<![CDATA[\n".freeze]
        compile_text!(temple, node, '    '.freeze)
        temple << [:static, "\n  //]]>\n</script>".freeze]
        temple
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
hamlit-2.2.4 lib/hamlit/filters/javascript.rb
hamlit-2.6.1 lib/hamlit/filters/javascript.rb
hamlit-2.6.0 lib/hamlit/filters/javascript.rb
hamlit-2.5.0 lib/hamlit/filters/javascript.rb
hamlit-2.4.2 lib/hamlit/filters/javascript.rb
hamlit-2.4.1 lib/hamlit/filters/javascript.rb
hamlit-2.4.0 lib/hamlit/filters/javascript.rb
hamlit-2.3.1 lib/hamlit/filters/javascript.rb
hamlit-2.3.0 lib/hamlit/filters/javascript.rb
hamlit-2.2.3 lib/hamlit/filters/javascript.rb
hamlit-2.2.2 lib/hamlit/filters/javascript.rb
hamlit-2.2.1 lib/hamlit/filters/javascript.rb
hamlit-2.2.0 lib/hamlit/filters/javascript.rb
hamlit-2.1.2 lib/hamlit/filters/javascript.rb
hamlit-2.1.1 lib/hamlit/filters/javascript.rb
hamlit-2.1.0 lib/hamlit/filters/javascript.rb
hamlit-2.0.2 lib/hamlit/filters/javascript.rb
hamlit-2.0.1 lib/hamlit/filters/javascript.rb