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 (in dev and test) 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

#around_template, component_name, #component_name

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

#entity, #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) ⇒ PageIdentifier

Create the component

Parameters:



6
7
8
# File 'lib/brut/front_end/components/page_identifier.rb', line 6

def initialize(page)
  @page = page
end

Instance Method Details

#view_templateObject



10
11
12
13
14
15
# File 'lib/brut/front_end/components/page_identifier.rb', line 10

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