Files
Umbraco-CMS/src/Umbraco.Web/UI/JavaScript/ServerVariablesParser.cs

34 lines
873 B
C#
Raw Normal View History

2013-05-26 19:54:50 -10:00
using System;
using System.Collections.Generic;
using Newtonsoft.Json.Linq;
namespace Umbraco.Web.UI.JavaScript
{
public sealed class ServerVariablesParser
2013-05-26 19:54:50 -10:00
{
/// <summary>
/// Allows developers to add custom variables on parsing
2013-05-26 19:54:50 -10:00
/// </summary>
public static event EventHandler<Dictionary<string, object>> Parsing;
2013-05-26 19:54:50 -10:00
internal const string Token = "##Variables##";
internal static string Parse(Dictionary<string, object> items)
{
var vars = Resources.ServerVariables;
2013-05-26 19:54:50 -10:00
//Raise event for developers to add custom variables
2013-05-26 19:54:50 -10:00
if (Parsing != null)
{
Parsing(null, items);
}
var json = JObject.FromObject(items);
2017-07-20 11:21:28 +02:00
return vars.Replace(Token, json.ToString());
2013-05-26 19:54:50 -10:00
}
2017-07-20 11:21:28 +02:00
2013-05-26 19:54:50 -10:00
}
2017-07-20 11:21:28 +02:00
}