Ejemplo n.º 1
0
        public string ReadTemplateFile(Context context, string templateName)
        {
            //var templatePath = (string)context[templateName];

            //if (templatePath == null || !Regex.IsMatch(templatePath, @"^[a-zA-Z0-9_]+$"))
            //    throw new FileSystemException("Error - Illegal template name '{0}'", templatePath);

            //var checkedLocations = new List<string>();
            //var viewPath = string.Empty;
            //var viewFound = false;

            //foreach (var fullPath in _viewLocations.Select(viewLocation => Path.Combine(viewLocation, string.Format(FileNameFormat, templatePath))))
            //{
            //    if(HostingEnvironment.VirtualPathProvider.FileExists(fullPath))
            //    {
            //        viewPath = fullPath;
            //        viewFound = true;
            //        break;
            //    }

            //    checkedLocations.Add(fullPath);
            //}

            //if (!viewFound)
            //    throw new FileSystemException("Error - No such template. Looked in the following locations:<br />{0}", string.Join("<br />", checkedLocations));

            //return VirtualPathProviderHelper.Load(viewPath);
            var templatePaths     = GetTemplatePaths(context, templateName);
            var themeAssetService = new ThemeAssetService();
            var themeAsset        = themeAssetService.Find(templatePaths);

            return(themeAsset.Value);
        }
Ejemplo n.º 2
0
        //public override object BeforeMethod(string singleKey)
        //{
        //    var single = LoadSingleObject(singleKey);

        //    if (single != null)
        //        return single;

        //    return null;
        //}

        //protected object LoadSingleObject(string alias)
        //{
        //    var settingData = LoadSetting();
        //    return settingData.Current[alias];
        //}

        public SettingData LoadSetting()
        {
            if (!_isLoadedSettings)
            {
                var settings          = new SettingsModel();
                var themeAssetService = new ThemeAssetService();
                var settingContent    = themeAssetService.GetContent(SETTING_FILE_PATH);
                var settingData       = SettingDataParser.Deserialize(settingContent);

                _loadedSettings.Add("settings", settingData);
                _isLoadedSettings = true;
                return(settingData);
            }
            else
            {
                return((SettingData)_loadedSettings["settings"]);
            }
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            //string path = @"E:\intership\dkt\project\TestLiquid\TestLiquid_Console\index.html";
            //var _html = System.IO.File.ReadAllText(path);
            //Template template = Template.Parse(_html);  // Parses and compiles the template
            //var tempBl = FindAllInstances<DotLiquid.Block>(template.Root);
            //var tempVar = FindAllInstances<DotLiquid.Variable>(template.Root);
            //string result = template.Render(Hash.FromAnonymousObject(new { name = "tobi" })); // Renders the output => "hi tobi"
            //System.Console.WriteLine(result);

            //var products = new List<Product>();
            //string result = Util.GenerateNameModelInContext(products);
            //System.Console.WriteLine(result);

            //var productService = new ProductService();
            //List<Product> products = productService.GetAll();
            //int countProduct = productService.CountAll();
            //Console.WriteLine(countProduct);

            //User user = new User
            //{
            //    String = "string 1",
            //    Number = 1,
            //    Teacher = new Teacher
            //    {
            //        Name = "name 2"
            //    }
            //};
            //List<String> temp = FindAllInstances<String>(user);

            var themeService      = new ThemeService();
            var themes            = themeService.GetAll();
            var themeAssetService = new ThemeAssetService();
            var themeAssets       = themeAssetService.GetAll(themes.ElementAt(0).Id);

            //var themeAsset = themeAssetService.GetByKey("templates/index.bwt", themes.ElementAt(0).Id);
            System.Console.ReadKey();
        }
Ejemplo n.º 4
0
        private Template FindTemplate(string templatePath)
        {
            Template template        = null;
            string   contentTemplate = "";

            if (IsEditableTemplate(templatePath))
            {
                var themeAssetService = new ThemeAssetService();
                contentTemplate = themeAssetService.GetContent(templatePath);
            }
            else
            {
                contentTemplate = VirtualPathProviderHelper.Load(templatePath);
            }
            if (!string.IsNullOrEmpty(contentTemplate))
            {
                template = Template.Parse(contentTemplate);
            }
            if (template == null)
            {
                template = Template.Parse(string.Format("Không tìm thấy template '{0}'", templatePath));
            }
            return(template);
        }