How to transfer data from plugin to app/views templates?

  1. I created a test page using the plugin help

By placing the following code in the appropriate files.
For example, in plugin.rb

Discourse::Application.routes.append do
  get '/help' => 'discourse_help/help#my_page'
end

load File.expand_path('../lib/dev/engine.rb', __FILE__)

engine.rb

module DiscourseHelp
  class Engine < ::Rails::Engine
    isolate_namespace DiscourseHelp

    config.after_initialize do
		Discourse::Application.routes.append do
			mount ::DiscourseHelp::Engine, at: "/"
		end
    end
  end
end

Etc.

I can see this page very well in my browser. Nicely. Included the second browser did the User Agent as a search engine and looked at this page as it is seen by the robots (search engines).

Robots do not see the content of the page, but only see:

Perfectly. I then decided to check and put to check already working plugins (for example, static pages, which were offered here). The result is similar.

Search engines do not see the content of the pages they create. I. e., I cannot use such pages for search engines.

I would like to know what are the ways to pass plugin content to templates at: app/views

I beg forgiveness for my English, Google translator used.


Another example about which I wrote above.

https://discourseleague.com/page/static-pages-plugin/1/

Etc. This is a general trend …

I think you should read through this series:

Pretty sure it is covered, you want to use the preload store here and then load it up on the client to avoid a double web request.

3 Likes