reutrns a nested menu
 Params:
 +item+:: hash of menu items
 +text+:: the hash value that you want to use as the title text
189480
def nested_dropdown(items, text = 'post_title')
      result = []
      items.map do |item, sub_items|
        name = text == 'post_title' && !item.parent.blank? && item.parent.disabled == 'Y' ? item[text.to_sym] + " (parent: #{item.parent.post_title})" : item[text.to_sym]
        result << [('- ' * item.depth) + name.html_safe, item[:id]]
        result += nested_dropdown(sub_items, text) unless sub_items.blank?
      end
      result
    end
830716
function() {
	   
	   // Keep corresponding text for each value selectable in the menu
	   //   -> will be used to display selection after click
	   this._textFromValue = {};
	   
	   var that = this;
	   
	   /*
	   * Recursive function to edit a level of menuItems
	   *
	   * args :
	   *   -> conf : an array of menuItems
	   *   -> level : how deeply nested are these menuItems (4 is max)
	   */
	   var levelInit = function (conf,level) {
	      if (level>4) throw new Error("MenuField : too much recursion, menuItems property should be 5 level deep at most.");
	      
	      var item;
	      for (var i=0, length = conf.length; i < length; i++) {
	         item = conf[i];
             if (YAHOO.lang.isUndefined(item.text) && !YAHOO.lang.isUndefined(item.value)) {
	            item.text = item.value;
	         }
	         if (YAHOO.lang.isUndefined(item.value) && !YAHOO.lang.isUndefined(item.text)) {
	            item.value = item.text;
	         }
	        
            // item with submenu
            //   -> explore deeper
	         if (!YAHOO.lang.isUndefined(item.submenu)) {
	            
	            // ensure there is an id on submenu (else submenu is not created)
	            if (YAHOO.lang.isUndefined(item.submenu.id)) {
	               item.submenu.id = YAHOO.util.Dom.generateId();
	            }
	            
	            // continue one level deeper
	            levelInit(item.submenu.itemdata,level+1);
	            
	         // item without submenu
	         //   -> add click listener to this item
	         //   -> pass selected value to the listener (as the 3rd argument)
	         } else {
	            that._textFromValue[item.value] = item.text;
	            item.onclick = {fn:function() {that.onItemClick.apply(that,arguments);},obj:item.value};
	         }
	      }
	   };
	   
	   levelInit(this.options.menuItems,0);
	   
	}
1073878
def title(custom_title_or_options = nil)
      case custom_title_or_options
      when Hash
        options = custom_title_or_options
      else
        options = {}
        custom_title = custom_title_or_options
      end

      title = custom_title
      catch(:exception) do
        title ||= t('.title', options.merge(throw: true))
      end

      provide(:page_title, title && title.html_safe) # "provide" already escapes
      content_tag(:h1, title) if title
    end
1262655
def menu text, &block
      m = Menu.new text, &block 
      m.color = @color
      m.bgcolor = @bgcolor
      add m
      return m
    end
396199
def admin_tools_render_menu_item(context, item, index=None):
    
    item.init_with_context(context)

    context.update({
        'template': item.template,
        'item': item,
        'index': index,
        'selected': item.is_selected(context['request']),
        'admin_url': reverse('%s:index' % get_admin_site_name(context)),
    })
    return context
338497
def core__generate_menu_item key, values, module_name
      menu_item = {}
      menu_item[:key] = key
      menu_item[:title] = values[:title] ? core__get_menu_title_translation(values[:title], module_name) : 'Undefined'
      menu_item[:icon] = values[:icon] ? values[:icon] : 'check-circle'
      menu_item[:url] = values[:url] ? values[:url] : ''
      menu_item[:position] = values[:position] ? values[:position] : 999
      menu_item[:permission_min] = values[:permission_min] ? values[:permission_min] : 0
      menu_item[:permission_max] = values[:permission_max] ? values[:permission_max] : 999
      menu_item[:sub_items] = []

      if values[:sub_items]
        values[:sub_items].each do |key, value|
          menu_item[:sub_items].push(core__generate_menu_sub_item(key, value, module_name))
        end
      end

      return menu_item
    end
229747
def title
      @title ||= begin
        if options[:title]
          options[:title]
        else
          title_builder = ''
          title_builder << "#{options[:value]} " if options[:value].is_a?(Symbol)
          title_builder << (options[:category].is_a?(Symbol) ? "per #{options[:category]}" : 'per request')
          title_builder
        end
      end
    end
1169428
def thing_params
      @params ||= thing.new.attributes.keys.map(&:to_sym)
      params.require(thing.name.underscore.to_sym).permit(
        @params,
        :page
      )
    end
60946
def submenu key, label, &block
      item = CMenuItem.new(key, label)
      @options << item
      item.action = PromptMenu.new @caller, label, &block
    end
48148
def cli_info(data, title='Info'):
    '''
    
    '''

    wrapper = textwrap.TextWrapper()
    wrapper.initial_indent = ' ' * 4
    wrapper.subsequent_indent = wrapper.initial_indent

    return '{title}:\n\n{text}'.format(title=title, text=wrapper.fill(data))
392026
def find_array_parents(toc, title)
      parents = ''
      toc.each do |item|
        if item.is_a?(Hash)
          parents = find_hash_parents(item, title)
          break unless parents.empty?
        end
      end
      parents
    end
1088776
def add(title_or_item, element_id=nil, options={}, &block)
      if element_id.is_a?(NSDictionary)
        options = element_id
        element_id = nil
      end

      if title_or_item.is_a?(NSMenuItem)
        item = title_or_item
        menu = nil
        retval = item
      elsif title_or_item.is_a?(NSMenu)
        menu = title_or_item
        item = self.item(menu.title, options)
        item.submenu = menu
        retval = menu
      else
        title = title_or_item
        item = self.item(title, options)

        if block
          menu = create(title)
          item.submenu = menu
          retval = menu
        else
          retval = item
        end
      end

      self.apply(:add_child, item)

      if menu && block
        menuitem_was = @menu_item
        @menu_item = item
        context(menu, &block)
        @menu_item = menuitem_was
      end

      if element_id
        create(retval, element_id)
      end

      return retval
    end
47051
def nav_title(self, article):
        
        article_title = article.metadata.front.article_meta.title_group.article_title.node
        return str(etree.tostring(article_title, method='text', encoding='utf-8'), encoding='utf-8')
576299
def _render_item(self, depth, key, value = None, **settings):
        
        strptrn  = self.INDENT * depth

        lchar = self.lchar(settings[self.SETTING_LIST_STYLE])
        s = self._es_text(settings, settings[self.SETTING_LIST_FORMATING])
        lchar = self.fmt_text(lchar, **s)

        strptrn = "{}"
        if value is not None:
            strptrn += ": {}"
        s = self._es_text(settings, settings[self.SETTING_TEXT_FORMATING])
        strptrn = self.fmt_text(strptrn.format(key, value), **s)

        return '{} {} {}'.format(self.INDENT * depth, lchar, strptrn)
112995
function() {

      var attrs, x, y, z, key, value, html, inputs, textarea;

      console.log(hashedit.current.node);

      if (hashedit.current.node !== null) {

        // get attributes
        attrs = hashedit.current.node.attributes;

        for (x = 0; x < attrs.length; x += 1) {

          // get key and value
          key = attrs[x].nodeName.replace(/-([a-z])/g, function(g) {
            return g[1].toUpperCase();
          });
          value = attrs[x].nodeValue;

          // if is numeric
          if (!isNaN(parseFloat(value)) && isFinite(value)) {
            value = parseFloat(value);
          }

          // set value
          inputs = document.querySelectorAll('[data-model="node.' + key + '"]');

          for (y = 0; y < inputs.length; y += 1) {
            inputs[y].value = value;
          }

        }

        // get html
        html = hashedit.current.node.innerHTML;

        // remove the element menu
        var i = html.indexOf('<span class="hashedit-element-menu"');
        html = html.substring(0, i);

        inputs = document.querySelectorAll('[data-model="node.html"]');

        for (y = 0; y < inputs.length; y += 1) {
          inputs[y].value = html;
        }


      }


    }
826372
function ( hash ) {
		var cuts = hash.split ( "/" );
		var name = cuts.pop () || "";
		if (( cuts = name.split ( "." )).length ) {
			cuts.pop ();
		}
		document.title = cuts.join ( "." );
	}
5113
def to_text(self):
        
        if self.items is None:
            return
        else:
            text = ''
            for item in self.items:
                text += ' - %s\n' % item.to_text()

            return text