FEATURE: Markdown support for product description (#21)

FEATURE: Markdown support for product description (#21)

diff --git a/app/controllers/discourse_subscriptions/products_controller.rb b/app/controllers/discourse_subscriptions/products_controller.rb
index 930a3cc..1032ba2 100644
--- a/app/controllers/discourse_subscriptions/products_controller.rb
+++ b/app/controllers/discourse_subscriptions/products_controller.rb
@@ -46,7 +46,7 @@ module DiscourseSubscriptions
       {
         id: product[:id],
         name: product[:name],
-        description: product[:metadata][:description],
+        description: PrettyText.cook(product[:metadata][:description]),
         subscribed: current_user_products.include?(product[:id])
       }
     end
diff --git a/assets/javascripts/discourse/templates/components/product-list.hbs b/assets/javascripts/discourse/templates/components/product-list.hbs
index 0734a78..1102445 100644
--- a/assets/javascripts/discourse/templates/components/product-list.hbs
+++ b/assets/javascripts/discourse/templates/components/product-list.hbs
@@ -6,7 +6,7 @@
       <h2>{{product.name}}</h2>
 
       <p class="product-description">
-        {{product.description}}
+        {{html-safe product.description}}
       </p>
 
       {{#if isLoggedIn}}
diff --git a/assets/javascripts/discourse/templates/s/show.hbs b/assets/javascripts/discourse/templates/s/show.hbs
index fa214ed..17ddaa8 100644
--- a/assets/javascripts/discourse/templates/s/show.hbs
+++ b/assets/javascripts/discourse/templates/s/show.hbs
@@ -8,7 +8,7 @@
     <hr>
 
     <p>
-      {{model.product.description}}
+      {{html-safe model.product.description}}
     </p>
   </div>
   <div class="section-column">
diff --git a/spec/requests/products_controller_spec.rb b/spec/requests/products_controller_spec.rb
index be290f0..5921843 100644
--- a/spec/requests/products_controller_spec.rb
+++ b/spec/requests/products_controller_spec.rb
@@ -32,7 +32,7 @@ module DiscourseSubscriptions
           expect(response.parsed_body).to eq([{
             "id" => "prodct_23456",
             "name" => "Very Special Product",
-            "description" => "Many people listened to my phone call with the Ukrainian President while it was being made",
+            "description" => PrettyText.cook("Many people listened to my phone call with the Ukrainian President while it was being made"),
             "subscribed" => false
           }])
         end
@@ -54,7 +54,7 @@ module DiscourseSubscriptions
             expect(response.parsed_body).to eq([{
               "id" => "prodct_23456",
               "name" => "Very Special Product",
-              "description" => "Many people listened to my phone call with the Ukrainian President while it was being made",
+              "description" => PrettyText.cook("Many people listened to my phone call with the Ukrainian President while it was being made"),
               "subscribed" => false
             }])
           end
@@ -86,7 +86,7 @@ module DiscourseSubscriptions
             expect(response.parsed_body).to eq(
               "id" => "prodct_23456",
               "name" => "Very Special Product",
-              "description" => "Many people listened to my phone call with the Ukrainian President while it was being made",
+              "description" => PrettyText.cook("Many people listened to my phone call with the Ukrainian President while it was being made"),
               "subscribed" => false
             )
           end

GitHub sha: 55e6accb

1 Like

This commit appears in #21 which was merged by justindirose.