I am facing this issue in c# code. While using liquid templates include formula.
string liquidTemplateContent = System.IO.File.ReadAllText("wwwroot/template/example.liquid");
LocalFileSystem fileSys = new DotLiquid.FileSystems.LocalFileSystem("wwwroot\\template");
Template.FileSystem = fileSys;
Template template = Template.Parse(liquidTemplateContent);
In following liquid file for {% include 'function' -%} this part, I'm facing this issue. Whenever the path coming under the error is valid path
And that _function.liquid file is also present over there.
error with path: Liquid error: Error - Illegal template path 'D:\Include Trial1\DotLiquidTest\wwwroot\template\_function.liquid'
<p>
Email: {{ employee.email }}
</p>
<p>
Phone: {{ employee.phone }}
</p>
<p>Addresses:</p>
<div>
{% include 'function' -%}
</div>
I am not sure what is missing here. I am using dotliquid NuGet package for the same.
Related
Im using Microsoft Visual Studio Community 2022 (64-bit), Version 17.2.4 and .net core 6.
In the .cshtml file I'm trying to check if ViewData["x"] is null or not like this:
#using System.Collections
#{
ViewData["Title"] = #Localizer["Title"];
var list = ViewData["EmailTypes"] != null ? (IEnumerable<SelectListItem>)ViewData["EmailTypes"] : null;
}
Im getting this errors:
Severity Code Description Project File Line Suppression State
Error (active) CS0119 'IEnumerable' is a type, which is not valid in the given context X
Severity Code Description Project File Line Suppression State
Error (active) CS1026 ) expected
Severity Code Description Project File Line Suppression State
Error (active) CS1003 Syntax error, ':' expected
Severity Code Description Project File Line Suppression State
Error (active) RZ1025 The "SelectListItem" element was not closed. All elements must be either self-closing or have a matching end tag.
Severity Code Description Project File Line Suppression State
Error (active) RZ1006 The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup.
But if I do like this:
#using System.Collections
#{
var list = ViewData["EmailTypes"] != null ? (IEnumerable<SelectListItem>)ViewData["EmailTypes"] : null;
ViewData["Title"] = #Localizer["Title"];
}
all errors disappear
how come this happens, and whats the best way to check if IEnumerableViewData["x"] is null or not?
ViewData["Title"] = #Localizer["Title"];
There's a "lost"(?) # symbol in that line, which confused the Razor compiler. Check the documentation for a proper syntax rules.
today i was trying to add Ninect.web.common to my project but surprisingly i received a strange error for the first time:
My project is running well and no build error at all, but as i try to add this package, i receive this error:
********** Action *********
public ActionResult Index()
{
......
return View((object)totalValue);
}
************** View **********
#model decimal
<div>
Total value:#Model
</div>
Error CS7003 Unexpected use of an unbound generic name
Error CS0037 Cannot convert null to 'decimal' because it is a non-nullable
Two errors are referencing the first line of view!
I removed previously installed Ninject packages and installed all of them form scratch!
Installation completed and now i can use Ninject in my project.
This error appears again if i try to update packeges!
In Visual Studio (Task Runner Explorer), I am trying to use gulp-sass-glob in my SCSS:
gulpfile.js
var gulp = require('gulp'),
sass = require('gulp-sass'),
sassGlob = require('gulp-sass-glob');
gulp.task('css', function () {
return gulp.src('./gulp/scss/**/*.scss')
.pipe(sassGlob())
.pipe(sourcemaps.init())
.pipe(sass({ outputStyle: 'compressed' }))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('./css'));
});
site.scss
#import "modules/**/*.*";
But in Task Runner Explorer, I get the following error:
Error: File to import not found or unreadable: modules/**/*.*
Parent style sheet: C:/Users/.../scss/site.scss
on line 95 of gulp/scss/site.scss
>> #import "modules/**/*.*";
Does anybody know how to fix this error or if this is even achievable when using SCSS and gulp in Visual Studio?
gulp-sass-glob uses the glob package for path globbing. Its documentation has this to say about **:
** If a "globstar" is alone in a path portion, then it matches zero or more directories and subdirectories searching for matches.
Notice the bolded part. It means ** only has special meaning when its the only thing between two slashes /.
Try the following in your site.scss:
#import "modules/**/*.*";
I'm using Orchard to build my website and want to add different elements for production environment and test environemnt in the Themes. I tried to use a c# singleton class in Orchard Themes class to get if it is production environment. Then use the singleton class in the cshtml file in Themes. The code can be compiled. But in run time, it will throw exception saying:The name 'Themes' does not exist in the current context. I have to add "Themes" namespace before the class I added. Otherwise, it won't pass compile.
Details:
I added a singleton class: EnvironmentDev.cs file into Themes.csproj file. It contains static GetInstance method and IsProd property.
In Themes.csproj file, it shows:
<ItemGroup>
<Compile Include="EnvironmentDev.cs" />
</ItemGroup>
In Document.cshtml file of Themes, I added following code:
#{
if (Themes.EnvironmentDev.GetInstance().IsProd) {
// Add production element
}
else {
// Add test site element
}
}
Detailed Error message:
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0103: The name 'Themes' does not exist in the current context
Source Error:
Line 46: #Display(Model.Head)
Line 47: #{
Line 48: if (Themes.EnvironmentDev.GetInstance().IsProd) {
Line 49: <script src="https://XXXX.js"></script> //using XXXX instead of real link
Line 50: }
Any suggestions would be appreciated.
I think you need to create a dedicated project for your theme with the following command
codegen theme MyTheme /CreateProject:true /IncludeInSolution:true
otherwise your code will not be found. I had the same issue with a resource file.
See paragraph Generating the Theme Structure in the docs for further information.
Getting error 'Umbraco.Cms.Web.BendyContentList' does not contain a definition for 'Children'
While trying to use
#inherits RenderViewPage
#using System.Web.Mvc.Html
#using Umbraco.Cms.Web;
#using Umbraco.Framework;
#using Umbraco.Framework.Persistence;
#{
ViewBag.Title = "FAQs";
Layout = "Layout.cshtml";
var accordionTitle = DynamicModel.Children.Where("NodeTypeAlias == \"supportAccordion\"");
var accordionItem = DynamicModel.Children.Where("NodeTypeAlias == \"supportAccordionItem\"");
}
<section class="support-wrapper">
<h1>Help & Frequently Asked Questions</h1>
<section class="questions">
#foreach (var item in accordionItem)
{
<h2>#accordionTitle.title</h2>
<h3>#item.question</h3>
<div>
<p>#item.answer</p>
</div>
}
</section><!-- end questions -->
</section><!-- end section wrapper -->
I've looked at http://our.umbraco.org/forum/core/umbraco-5-general-discussion/27856-razor-in-Umbraco-5-filtering-child-nodes-by-doc-type But still not working.
My Umbraco tree looks like the following. I've put the Document Type name in Red.
There's not much documentation out on Umbraco 5 yet as it was recently released. Does anyone know what could be the issue?
Thanks!
I think you're running on an older release than the RTM, as BendyContentList was removed from the codebase and the code you have should work fine.
Could you check the version you're running? This can be done by checking the About button the top right corner of the backoffice.