I was hoping to add information to posts in the plugin.rb file using add_to_serializer
, and then access that data in my plugin’s default initializer file using decorateWidget
from the api.
My plugin.rb contains
after_initialize do
add_to_serializer :post, :foo do
return "bar"
end
end
From what I understand, the code should be adding a ‘foo’ attribute (with a value of ‘bar’) to each serialized post.
My only javascript initializer contains:
import { withPluginApi } from 'discourse/lib/plugin-api';
export default {
name: 'my-test',
initialize() {
withPluginApi("0.8.23", api => {
api.decorateWidget('post-avatar:after', helper => {
console.log(helper.attrs);
});
});
}
}
The admin plugins page shows that my plugin is installed, but when I view the output in my browsers console, I do not see the ‘foo’ attribute. Obviously, I’m doing something wrong, and I would greatly appreciate some knowledge.