Fixed frontend HTML display

This commit is contained in:
Matt-Yorkley
2016-11-17 14:46:00 +00:00
committed by Rob Harrington
parent c43dea60b7
commit b38eab11eb
2 changed files with 11 additions and 5 deletions

View File

@@ -14,10 +14,9 @@
.filter-shopfront.property-selectors.inline-block
%filter-selector{ 'selector-set' => "productPropertySelectors", objects: "[product] | propertiesWithValuesOf" }
%div{"ng-if" => "product.description"}
%div{"ng-if" => "product.description_html"}
%hr
%p.text-small{"ng-bind" => "::product.description"}
{{product.description}}
%p.text-small{"ng-bind-html" => "product.description_html"}
%hr
.columns.small-12.large-6

View File

@@ -37,7 +37,7 @@ class Api::CachedProductSerializer < ActiveModel::Serializer
include ActionView::Helpers::SanitizeHelper
attributes :id, :name, :permalink
attributes :on_demand, :group_buy, :notes, :description
attributes :on_demand, :group_buy, :notes, :description, :description_html
attributes :properties_with_values
has_many :variants, serializer: Api::VariantSerializer
@@ -49,8 +49,15 @@ class Api::CachedProductSerializer < ActiveModel::Serializer
has_many :images, serializer: Api::ImageSerializer
has_one :supplier, serializer: Api::IdSerializer
#return an unformatted descripton
def description
sanitize(object.description, options = {tags: "p, b, strong, em, i"}).html_safe
strip_tags object.description
end
#return a sanitized html description
def description_html
d = sanitize(object.description, options = {tags: "p, b, strong, em, i"})
d.to_s.html_safe
end
def properties_with_values