Class: Brut::FrontEnd::Components::PageIdentifier

Inherits:
Brut::FrontEnd::Component show all
Defined in:
lib/brut/front_end/components/page_identifier.rb

Overview

Renders a <meta> tag that contains the name of the page. This is useful for end to end tests to assert that they are on a specific page before continuing with the test. It can eliminate a lot of confusion when a test fails.

Instance Method Summary collapse

Methods inherited from Brut::FrontEnd::Component

component_name, #component_name

Methods included from Brut::FrontEnd::Component::Helpers

#global_component, #inline_svg

Methods included from I18n::ForHTML

#html_escape, #t

Methods included from I18n::BaseMethods

#l, #t, #t_direct, #this_field_value

Methods included from Brut::Framework::Errors

#abstract_method!, #bug!

Constructor Details

#initialize(page_name) ⇒ PageIdentifier

Returns a new instance of PageIdentifier.



3
4
5
# File 'lib/brut/front_end/components/page_identifier.rb', line 3

def initialize(page_name)
  @page_name = page_name
end

Instance Method Details

#view_templateObject



7
8
9
10
11
12
# File 'lib/brut/front_end/components/page_identifier.rb', line 7

def view_template
  if Brut.container.project_env.production?
    return nil
  end
  meta(name: "class", content: @page_name)
end