Sha256: 288982628434664ea19056d70ac5d096904ed9242282f0253c83749ce440f633

Contents?: true

Size: 637 Bytes

Versions: 2

Compression:

Stored size: 637 Bytes

Contents

# frozen_string_literal: true

module Staticky
  module Phlex
    module ViewHelpers
      def helpers
        @_view_context
      end

      def staticky_live_reload_js(base_path = "/")
        script(type: :module) do
          unsafe_raw Staticky::Utils.live_reload_js(base_path)
        end
      end

      def link_to(text = nil, href, **, &block) # rubocop:disable Style/OptionalArguments
        block ||= proc { text }
        href = Staticky.router.resolve(href)
        href = href.uri.to_s unless href.is_a?(String)

        a(href:, **, &block)
      end
    end
  end
end

Phlex::SGML.prepend Staticky::Phlex::ViewHelpers

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
staticky-0.3.1 lib/staticky/phlex/view_helpers.rb
staticky-0.3.0 lib/staticky/phlex/view_helpers.rb