How to customize routes and render custom pages in a plugin?

In a plugin, how do I customize routes and then render a custom page?

I looked at this post: Developing Discourse Plugins - Part 5 - Add an Admin Interface - Docs / Developer Guide - Discourse Meta, and other plugins, but they all failed.

My custom routes are returning JSON data, but what I want is to render an Ember template. Is there a post that explains this related knowledge? Thank you very much.

If that’s all you want to do, take a look at:

And:

3 Likes

(post deleted by author)

I am currently stuck here, here are my specific steps:

I defined the route in the file plugins/q/config/routes.rb:

get "/hello" => "examples#hello"

Controller: plugins/q/app/controllers/quectel/examples_controller.rb

def hello
   render json: { hello: "world" }
end

Now visiting: localhost:4200/q/hello, returns json

{"hello":"world"}

How can I render the Ember template when visiting localhost:4200/q/q/hello?

I bookmarked this topic some time ago to read later: Creating Routes in Discourse and Showing Data. Not sure if it’s up-to-date, but maybe it’ll still help.

(post deleted by author)

Yes, I also read this post and followed the steps above, but it didn’t work, and an “Page not found” error appeared. Then, I was confused.