Sha256: a54d70afe1f5704df4aa8b08baa639c89a65f29bec3c1483a483716335db3c39

Contents?: true

Size: 938 Bytes

Versions: 17

Compression:

Stored size: 938 Bytes

Contents

# -*- coding: utf-8 -*- #

module Rouge
  module Lexers
    class EEX < TemplateLexer
      title "EEX"
      desc "Embedded Elixir"

      tag 'eex'
      aliases 'leex'

      filenames '*.eex', '*.leex'

      def initialize(opts={})
        @elixir_lexer = Elixir.new(opts)

        super(opts)
      end

      start do
        parent.reset!
        @elixir_lexer.reset!
      end

      open  = /<%%|<%=|<%#|<%/
      close = /%%>|%>/

      state :root do
        rule %r/<%#/, Comment, :comment

        rule open, Comment::Preproc, :elixir

        rule %r/.+?(?=#{open})|.+/mo do
          delegate parent
        end
      end

      state :comment do
        rule close, Comment, :pop!
        rule %r/.+?(?=#{close})|.+/mo, Comment
      end

      state :elixir do
        rule close, Comment::Preproc, :pop!

        rule %r/.+?(?=#{close})|.+/mo do
          delegate @elixir_lexer
        end
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
rouge-3.26.1 lib/rouge/lexers/eex.rb
mumukit-content-type-1.11.1 vendor/bundle/ruby/2.6.0/gems/rouge-3.26.0/lib/rouge/lexers/eex.rb
rouge-3.26.0 lib/rouge/lexers/eex.rb
rouge-3.25.0 lib/rouge/lexers/eex.rb
rouge-3.24.0 lib/rouge/lexers/eex.rb
rouge-3.23.0 lib/rouge/lexers/eex.rb
rouge-3.22.0 lib/rouge/lexers/eex.rb
rouge-3.21.0 lib/rouge/lexers/eex.rb
rouge-3.20.0 lib/rouge/lexers/eex.rb
rouge-3.19.0 lib/rouge/lexers/eex.rb
rouge-3.18.0 lib/rouge/lexers/eex.rb
rouge-3.17.0 lib/rouge/lexers/eex.rb
rouge-3.16.0 lib/rouge/lexers/eex.rb
rouge-3.15.0 lib/rouge/lexers/eex.rb
rouge-3.14.0 lib/rouge/lexers/eex.rb
rouge-3.13.0 lib/rouge/lexers/eex.rb
rouge-3.12.0 lib/rouge/lexers/eex.rb