Fixing Json formatting in Shape Tracing

--HG--
branch : 1.x
This commit is contained in:
Sebastien Ros
2011-05-10 20:49:17 -07:00
parent 4e742d28b3
commit 123e4681f3
2 changed files with 5 additions and 4 deletions

View File

@@ -190,7 +190,7 @@ namespace Orchard.DesignerTools.Services {
}
}
private static string FormatJsonValue(string value) {
public static string FormatJsonValue(string value) {
// replace " by \" in json strings
return value.Replace(@"\", @"\\").Replace("\"", @"\""").Replace("\r\n", @"\n").Replace("\r", @"\n").Replace("\n", @"\n");
}

View File

@@ -1,4 +1,5 @@
@using Orchard.Utility.Extensions;
@using Orchard.DesignerTools.Services;
@functions {
string FormatShapeName(string shape) {
@@ -59,14 +60,14 @@ shapeTracingMetadataHost[@Model.ShapeId].shape = {
</text>
}
],
html: '@RemoveEmptyLines(RemoveBeacons(Display(Model.ChildContent).ToString())).Replace(Environment.NewLine, "\\n")',
templateContent: '@(String.IsNullOrWhiteSpace((string)Model.TemplateContent) ? @T("Content not available as coming from source code.") : @Model.TemplateContent.Replace(Environment.NewLine, "\\n"))',
html: '@ShapeTracingFactory.FormatJsonValue(RemoveEmptyLines(RemoveBeacons(Display(Model.ChildContent).ToString())))',
templateContent: '@(ShapeTracingFactory.FormatJsonValue(String.IsNullOrWhiteSpace((string)Model.TemplateContent) ? @T("Content not available as coming from source code.").ToString() : (string)Model.TemplateContent))',
model: { @(new MvcHtmlString((string)@Model.Dump)) }
};
@if (!String.IsNullOrEmpty((string)Model.PlacementSource) && (WorkContext.HttpContext.Items[(string)Model.PlacementSource] == null)) {
WorkContext.HttpContext.Items[(string)Model.PlacementSource] = new object();
<text>shapeTracingMetadataHost.placement['@Model.PlacementSource.ToString()'] = '@Model.PlacementContent.Replace(Environment.NewLine, "\\n")'; </text>
<text>shapeTracingMetadataHost.placement['@Model.PlacementSource.ToString()'] = '@ShapeTracingFactory.FormatJsonValue((string)Model.PlacementContent)'; </text>
}
</script>