Returns the rabl template path for Rails, including special lookups for Rails 2 and 3
12638
def fetch_rails_source(file, options = {})
        # use Rails template resolution mechanism if possible (find_template)
        source_format = request_format if defined?(request_format)

        if source_format && context_scope.respond_to?(:lookup_context) # Rails 3
          lookup_proc = lambda do |partial|
            if ActionPack::VERSION::MAJOR == 3 && ActionPack::VERSION::MINOR < 2
              context_scope.lookup_context.find(file, [], partial)
            else # Rails 3.2 and higher
              # pull format directly from rails unless it is html
              request_format = context_scope.request.format.to_sym
              source_format = request_format unless request_format == :html
              context_scope.lookup_context.find(file, [], partial, [], { :formats => [source_format] })
            end
          end
          template = lookup_proc.call(false) rescue nil
          template ||= lookup_proc.call(true) rescue nil
          template.identifier if template
        elsif source_format && context_scope.respond_to?(:view_paths) # Rails 2
          template = context_scope.view_paths.find_template(file, source_format, false)
          template.filename if template
        end
      end
534902
def get_template(name):
    
    path = pkg_resources.resource_filename('vr.runners', 'templates/' + name)
    with open(path, 'r') as f:
        return f.read()
35216
def grok_template_file(src):
    """"""
    if not src.startswith('builtin:'):
        return abspath(src)

    builtin = src.split(':')[1]
    builtin = "templates/%s.j2" % builtin
    return resource_filename(__name__, builtin)
382397
def browse_catalog_for_a_template(catalog_path, template_name)
      template_path = catalog_path.join(template_name)

      if Dir.exist?(template_path)
        return template_path
      end

      return nil
    end
903662
def find_template_path(name):
    
    global template_source_loaders
    if template_source_loaders is None:
        loaders = []
        for loader_name in settings.TEMPLATE_LOADERS:
            loader = find_template_loader(loader_name)
            if loader is not None:
                loaders.append(loader)
        template_source_loaders = tuple(loaders)
    for loader in template_source_loaders:
        try:
            _, display_name = loader(name)
            if display_name:
                return display_name
        except TemplateDoesNotExist:
            pass
    raise TemplateDoesNotExist(name)
1016542
def partial_path(filename)
      return filename if filename.nil? || Pathname.new(filename).absolute?

      # try relative to template
      if template
        base_folder = File.dirname(template)
        filename = File.expand_path(File.join(base_folder, filename))
        return filename if File.exists?(filename)
      end

      # try relative to PWD
      filename = File.expand_path(File.join(FileUtils.pwd, filename))
      return filename if File.exists?(filename)

      # try built in template folder
      filename = File.expand_path(File.join('../templates', filename), __FILE__)
    end
1114568
def template
      File.read("#{Dir.home}/.gem_updater_template.erb")
    rescue Errno::ENOENT
      File.read(File.expand_path('../lib/gem_updater_template.erb', __dir__))
    end
417476
def get_theme_options

      hash = []
      Dir.glob("#{Rails.root}/app/views/themes/*/") do |themes|
        opt = themes.split('/').last
        if File.exists?("#{themes}theme.yml")
          info = YAML.load(File.read("#{themes}theme.yml"))
          hash << info if !info['name'].blank? && !info['author'].blank? && !info['foldername'].blank? && !info['view_extension'].blank?
        end
      end

      hash
    end
95490
def get_templates
      hash = []
      current_theme = Setting.get('theme_folder')

      Dir.glob("#{Rails.root}/app/views/themes/#{current_theme}/template-*.html.erb") do |my_text_file|
        opt = my_text_file.split('/').last
        opt['template-'] = ''
        opt['.html.erb'] = ''
        # strips out the template- and .html.erb extention and returns the middle as the template name for the admin
        hash << opt.titleize
      end

      hash
    end
761482
def paths
      relative_paths = gem_names.flat_map do |plugin|
        Dir.glob("vendor/gems/ruby/*/gems/#{plugin}*/lib/**/**/**/**.rb")
      end

      relative_paths.map { |path| File.join(dir, path) }
    end
956232
def find_template(t)
      x = menus[t]
      if x
        return x, Gopher::Rendering::Menu
      end
      x = text_templates[t]
      if x
        return x, Gopher::Rendering::Text
      end
    end
317214
def result
      @task = 'railsbp'
      @path = discover_path

      return unless is_rails? && temp_config(@task) && path_exists?(@path)

      tmp = Tempfile.new('railsbp')
      `rails_best_practices #{@path} -f json --output-file #{tmp.path}`
      railsbp = tmp.read
      tmp.close
      tmp.unlink

      unless railsbp.blank?
        rbj = JSON.parse(railsbp).group_by { |s| s['filename'] }
        railsbp = {}
        rbj.each do |file, errors|
          next unless file

          # This crazy gsub scrubs the absolute path from the filename
          filename = file.gsub(Rails.root.to_s, '')[1..-1]
          railsbp[filename] = errors.map { |o| hash_for_railsbp(o) }

        end
      end

      @output[:files_inspected] ||= files_inspected('rb', ' ')
      refine railsbp
    end
273085
def render
      Mustache.view_namespace = self.class

      result = {}
      self.class.views.each do |view_name|
        template = File.join 'templates', "#{view_name}.mustache"
        template_path = self.class.find template

        view = File.join 'views', "#{view_name}.rb"
        view_path = self.class.find view

        Mustache.template_path = File.dirname template_path
        Mustache.view_path     = File.dirname view_path
        mustache = Mustache.view_class(view_name).new(self)
        mustache.template_name = view_name
        result[view_name] = mustache.render
      end
      result
    end
1350722
def template_include_tag(*sources)
      options = sources.extract_options!
      sources.collect do |source|
        template_finder = lambda do |partial|
          if ActionPack::VERSION::MAJOR == 3 && ActionPack::VERSION::MINOR < 2
            lookup_context.find(source, [], partial)
          else # Rails 3.2 and higher
            lookup_context.find(source, [], partial, [], { formats: [:html] })
          end
        end

        template = template_finder.call(true) rescue template_finder.call(false)
        template_id = (Stache.include_path_in_id) ? source.gsub("/", '_') : source.to_s.split("/").last
        content_tag(:script, template.source.html_safe, options.reverse_merge(type: 'text/html', id: template_id.dasherize.underscore))

      end.join("\n").html_safe
    end
593641
def get_template_folder():
    """"""
    cfg = get_project_configuration()
    if 'templates' not in cfg:
        home = os.path.expanduser("~")
        rcfile = os.path.join(home, ".hwrtrc")
        cfg['templates'] = pkg_resources.resource_filename('hwrt',
                                                           'templates/')
        with open(rcfile, 'w') as f:
            yaml.dump(cfg, f, default_flow_style=False)
    return cfg['templates']
812262
def get_routes_doc
      puts "Executing 'rake routes'..." if trace?

      routes_doc = RoutesDoc.new
      routes = Dir.chdir( ::Rails.root.to_s ) { `rake routes` }

      routes.split("\n").each do |entry|
        routes_doc.add_route( entry ) unless entry.match(/URI/)
      end

      routes_doc
    end
1168746
def render(options=nil, deprecated_status_or_extra_options=nil, &block)
      if ::Rails::VERSION::STRING >= '2.0.0' && deprecated_status_or_extra_options.nil?
        deprecated_status_or_extra_options = {}
      end

      unless block_given?
        if @template.respond_to?(:finder)
          (class << @template.finder; self; end).class_eval do
            define_method :file_exists? do; true; end
          end
        else
          (class << @template; self; end).class_eval do
            define_method :file_exists? do; true; end
          end
        end
        (class << @template; self; end).class_eval do
          define_method :render_file do |*args|
            @first_render ||= args[0] unless args[0] =~ /^layouts/
            @_first_render ||= args[0] unless args[0] =~ /^layouts/
          end

          define_method :_pick_template do |*args|
            @_first_render ||= args[0] unless args[0] =~ /^layouts/
            PickedTemplate.new
          end
        end
      end

      super(options, deprecated_status_or_extra_options, &block)
    end