# Editing posts using a Theme Component

**URL:** <https://meta.discourse.org/t/editing-posts-using-a-theme-component/381671>\
**Category:** Development\
**Created:** [September 5, 2025, 3:18am UTC](https://meta.discourse.org/t/editing-posts-using-a-theme-component/381671 "2025-09-05T03:18:28Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![NateDhaliwal](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/natedhaliwal/32/313494_2.png) [@NateDhaliwal](https://meta.discourse.org/u/NateDhaliwal)\
**Post date:** [September 5, 2025, 9:41am UTC](https://meta.discourse.org/t/editing-posts-using-a-theme-component/381671/2 "2025-09-05T09:41:23Z")

</div>

Okay, I think I’m getting ~~closer~~ very close now.

~~I tried `this.post.save()` and it apparently “works” - it seems like the PUT request is going through (using ajax under the hood), but was met with some error with little to no information. But that was before this…~~

The `this.post.save()` works. The only problem is the one listed below:

My function is now like this:

````js
@action
async addCodeFences() {
  let selectedText = this.selectedText;
  let newText = "```" + "\n" + selectedText + "\n" + "```";

  let post = this.post;
  console.log(this.post.cooked); // Works

  let rawPost = post.raw; // Doesn't exist!!
  console.log(rawPost); // undefined!

  rawPost.replace(selectedText, "\n" + newText + "\n"); // Error, since rawPost is undefined!

  await this.post.save({
    raw: rawPost,
    edit_reason: I18n.t(themePrefix("add_code_fence_edit_reason"))
  });
}

````

For some reason, I cannot get the post’s raw contents, only the cooked. Besides doing an ajax request, is there a way to do it? I can’t seem to find `raw` as one of the attributes for the post… is there a reason why it isn’t included?

P.S. I’m trying not to turn to Ask Discourse here. I would really appreciate any help!

* * *

EDIT: I think each post is based of [this API request](https://docs.discourse.org/#tag/Topics/operation/getSpecificPostsFromTopic)? And the response doesn’t seem to have `raw` as one of the JSON keys 😮‍💨.

---

_[View the full topic](https://meta.discourse.org/t/editing-posts-using-a-theme-component/381671)._
