<commit_before>module Locomotive
  module PagesHelper

    def extendable_pages_options
      hash = {}
      current_site.extendable_pages.each do |page|
        hash[page.title] = page.slug
      end
      hash["Parent"] = "parent"
      hash
    end

    def functions_for_select
      @function_content_type ||= current_site.content_types.functions.first
      hash = {}
      return hash unless @function_content_type.present?
      @function_content_type.entries.each {|e| hash[e.name] = e._id }
      return hash
    end

    def groups_for_select
      @group_content_type ||= current_site.content_types.groups.first
      hash = {}
      return hash unless @group_content_type.present?
      @group_content_type.entries.each {|e| hash["#{e.function.name} / #{e.name}"] = e._id }
      return hash
    end

    def grades_for_select
      @grade_content_type ||= current_site.content_types.grades.first
      hash = {}
      return hash unless @grade_content_type.present?
      @grade_content_type.entries.each {|e| hash[e.name] = e._id }
      return hash
    end

    def css_for_page(page)
      classes = %w(index not_found templatized redirect unpublished).inject([]) do |memo, state|
        memo << state.dasherize if page.send(:"#{state}?")
        memo
      end
      return classes.join(" ")
    end

    def page_toggler(page)
      icon_class = cookies["folder-#{page._id}"] != 'none' ? 'icon-caret-down' : 'icon-caret-right'
      content_tag :i, '',
        class:  "#{icon_class} toggler",
        data:   {
          open:   'icon-caret-down',<commit_msg>Fixed pages helper to not error out page when can't find function<commit_after>module Locomotive
  module PagesHelper

    def extendable_pages_options
      hash = {}
      current_site.extendable_pages.each do |page|
        hash[page.title] = page.slug
      end
      hash["Parent"] = "parent"
      hash
    end

    def functions_for_select
      @function_content_type ||= current_site.content_types.functions.first
      hash = {}
      return hash unless @function_content_type.present?
      @function_content_type.entries.each {|e| hash[e.name] = e._id }
      return hash
    end

    def groups_for_select
      @group_content_type ||= current_site.content_types.groups.first
      hash = {}
      return hash unless @group_content_type.present?
      @group_content_type.entries.each {|e| hash["#{e.function.try(:name)} / #{e.name}"] = e._id }
      return hash
    end

    def grades_for_select
      @grade_content_type ||= current_site.content_types.grades.first
      hash = {}
      return hash unless @grade_content_type.present?
      @grade_content_type.entries.each {|e| hash[e.name] = e._id }
      return hash
    end

    def css_for_page(page)
      classes = %w(index not_found templatized redirect unpublished).inject([]) do |memo, state|
        memo << state.dasherize if page.send(:"#{state}?")
        memo
      end
      return classes.join(" ")
    end

    def page_toggler(page)
      icon_class = cookies["folder-#{page._id}"] != 'none' ? 'icon-caret-down' : 'icon-caret-right'
      content_tag :i, '',
        class:  "#{icon_class} toggler",
        data:   {
          open:   'icon-caret-down',
{'fraction_non_alphanumeric': 0.11677018633540373, 'fraction_numerical': 0.0, 'mean_word_length': 2.7022988505747128, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6872701', 'n_tokens_mistral': 1032, 'n_tokens_neox': 1034, 'n_words': 212}