Yeoman Generator - utils is not defined - generator

I can't generate following file with this markup
<div class="animatedCarouselItems <%= site_name %>">
${utils.InlineStyleSheet.get("productions/<%= site_name %>/<%= site_name %>.css").raw()}
<div class="productionHomeStage">
<img class="stageBg" src="#{'/public/images/productionhomestage/<%= site_name %>/<%= site_name %>_bg.jpg'}" alt="">
</div>
Site_name should be overwritten with the appname.
I get following error:
vents.js:72
throw er; // Unhandled 'error' event
^
ReferenceError: utils is not defined
at eval (eval at <anonymous> (/Users/sergejr/Documents/development/_projects/yeoman-generator/generator-copyDev/node_modules/yeoman-generator/node_modules/lodash/index.js:10747:16), <anonymous>:10:10)
at underscore (/Users/sergejr/Documents/development/_projects/yeoman-generator/generator-copyDev/node_modules/yeoman-generator/lib/util/engines.js:23:45)
at actions.engine (/Users/sergejr/Documents/development/_projects/yeoman-generator/generator-copyDev/node_modules/yeoman-generator/lib/actions/actions.js:224:32)
at template (/Users/sergejr/Documents/development/_projects/yeoman-generator/generator-copyDev/node_modules/yeoman-generator/lib/actions/actions.js:198:19)
at yeoman.generators.Base.extend.copyMainFiles (/Users/sergejr/Documents/development/_projects/yeoman-generator/generator-copyDev/generators/app/index.js:60:10)
at /Users/sergejr/Documents/development/_projects/yeoman-generator/generator-copyDev/node_modules/yeoman-generator/lib/base
When there is no placeholder it can generate this file with
this.template("html/carousel/_carousel.html", folderHTML + "carousel/" + this.appName + ".html", siteTitle);
Any Ideas?

Related

Triple mustache to escape value erroring in Angular app

I've tried this in several different angular apps and get the same error. I've verified that the latest version of Handlebars is installed. Whenever I try to use the triple mustache {{{ }}} to render html as html within an html file, the compiler throws this error (I'm using VSCode, but the same error occurs within the stackblitz below):
Template parse errors:
Parser Error: Missing expected : at the end of the expression [{{{item}}}] in ng:///AppModule/AppComponent.html#9:37 ("DropListEnterPredicate]="enter" (cdkDropListDropped)="drop()">
<div cdkDrag class="example-box">[ERROR ->]{{{item}}}</div>
</div>
</div> "): ng:///AppModule/AppComponent.html#9:37
Parser Error: Unexpected end of expression: {{{item}}} at the end of the expression [{{{item}}}] in ng:///AppModule/AppComponent.html#9:37 ("DropListEnterPredicate]="enter" (cdkDropListDropped)="drop()">
<div cdkDrag class="example-box">[ERROR ->]{{{item}}}</div>
</div>
</div> "): ng:///AppModule/AppComponent.html#9:37
Parser Error: Missing expected } at the end of the expression [{{{item}}}] in ng:///AppModule/AppComponent.html#9:37 ("DropListEnterPredicate]="enter" (cdkDropListDropped)="drop()">
<div cdkDrag class="example-box">[ERROR ->]{{{item}}}</div>
</div>
</div> "): ng:///AppModule/AppComponent.html#9:37
I've copied a simple stackblitz, in it I've duplicated the error by putting the triple braces around the {{{item}}}.
https://stackblitz.com/edit/angular-4kmtwp
I've tried { {{ item }} }, {{ '{' }} {{ item }} {{ '}' }}, &123;&123;&123; item &125;&125;&125; but none of those render the html.
The solution was to change the line:
<div cdkDrag class="example-box">{{{item}}}</div>
to
<div cdkDrag class="example-box" [innerHtml]="item"></div>
As an additional note, if there are class names within the innerHtml that you need to style, you may need to set the encapsulation within the typescript file as ViewEncapsulation.None.
i.e. encapsulation: ViewEncapsulation.None

org.thymeleaf.exceptions.TemplateProcessingException: Exception evaluating SpringEL expression: "#request.userPrincipal.name"

Whenever I am trying to run my web application I am getting the error below.
Can you please help.
2019-04-17 07:33:13.881 ERROR 21660 --- [io-9393-exec-10] org.thymeleaf.TemplateEngine : [THYMELEAF][http-nio-9393-exec-10] Exception processing template "index": Exception evaluating SpringEL expression: "#request.userPrincipal.name" (template: "/_header" - line 10, col 48)
org.thymeleaf.exceptions.TemplateProcessingException: Exception evaluating SpringEL expression: "#request.userPrincipal.name" (template: "/_header" - line 10, col 48)
Caused by: org.springframework.expression.spel.SpelEvaluationException: EL1007E: Property or field 'name' cannot be found on null
My header.html looks like this
<div class="header-bar">
<th:block sec:authorize="isAuthenticated()">
Hello
<a th:href="#{/admin/accountInfo}" th:utext="${#request.userPrincipal.name}">..</a>
|
<a th:href="#{/admin/logout}">Logout</a>
</th:block>
<th:block sec:authorize="!isAuthenticated()">
<a th:href="#{/admin/login}">Login</a>
</th:block>
</div>
Try modify the code like this
<div class="header-container"
xmlns:th="http://www.thymeleaf.org"
xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity">
And update the porn.xml
<dependency>
<groupId>org.thymeleaf.extras</groupId>
<artifactId>thymeleaf-extras-springsecurity5</artifactId>
</dependency>
It will work correctly
This looks like the code (isAuthenticated) is not taking effect.
Try updating your pom file to use the following version:
thymeleaf-extras-springsecurity5
And update your html header file to:
xmlns:sec="http://www.thymeleaf.org/extras/spring-security"

ejs - template variable is not defined

i'm a web noob and I couldn't find an answer that solved my case:
I'm trying to pass on a variable called catURL to my html file but when I try to render it, it fails.
This is how I pass the variable:
res.render('index', {catURL: url, error: null});
This is where I try to show it in my html:
<div id="Wax on" class="tabcontent">
<h3>Wax on</h3>
<p>Dont forget to wax off!!!</p>
<% if(catURL !== null){ %>
<img src="<%= catURL %>" />
<% } %>
</div>
This is the error msg that I get:
ReferenceError: /Users/nimrodshai/Documents/Projects/WeatherJS/views/index.ejs:21
19| <h3>Wax on</h3>
20| <p>Dont forget to wax off!!!</p>
>> 21| <% if(catURL !== null){ %>
22| <img src="<%= catURL %>" />
23| <% } %>
24| </div>
catURL is not defined
at eval (eval at compile (/Users/nimrodshai/Documents/Projects/WeatherJS/node_modules/ejs/lib/ejs.js:618:12), <anonymous>:11:8)
at returnedFn (/Users/nimrodshai/Documents/Projects/WeatherJS/node_modules/ejs/lib/ejs.js:653:17)
at tryHandleCache (/Users/nimrodshai/Documents/Projects/WeatherJS/node_modules/ejs/lib/ejs.js:251:36)
at View.exports.renderFile [as engine] (/Users/nimrodshai/Documents/Projects/WeatherJS/node_modules/ejs/lib/ejs.js:482:10)
at View.render (/Users/nimrodshai/Documents/Projects/WeatherJS/node_modules/express/lib/view.js:135:8)
at tryRender (/Users/nimrodshai/Documents/Projects/WeatherJS/node_modules/express/lib/application.js:640:10)
at Function.render (/Users/nimrodshai/Documents/Projects/WeatherJS/node_modules/express/lib/application.js:592:3)
at ServerResponse.render (/Users/nimrodshai/Documents/Projects/WeatherJS/node_modules/express/lib/response.js:1008:7)
at /Users/nimrodshai/Documents/Projects/WeatherJS/server.js:14:6
at Layer.handle [as handle_request] (/Users/nimrodshai/Documents/Projects/WeatherJS/node_modules/express/lib/router/layer.js:95:5)
at next (/Users/nimrodshai/Documents/Projects/WeatherJS/node_modules/express/lib/router/route.js:137:13)
at Route.dispatch (/Users/nimrodshai/Documents/Projects/WeatherJS/node_modules/express/lib/router/route.js:112:3)
at Layer.handle [as handle_request] (/Users/nimrodshai/Documents/Projects/WeatherJS/node_modules/express/lib/router/layer.js:95:5)
at /Users/nimrodshai/Documents/Projects/WeatherJS/node_modules/express/lib/router/index.js:281:22
at Function.process_params (/Users/nimrodshai/Documents/Projects/WeatherJS/node_modules/express/lib/router/index.js:335:12)
at next (/Users/nimrodshai/Documents/Projects/WeatherJS/node_modules/express/lib/router/index.js:275:10)
at urlencodedParser (/Users/nimrodshai/Documents/Projects/WeatherJS/node_modules/body-parser/lib/types/urlencoded.js:91:7)
at Layer.handle [as handle_request] (/Users/nimrodshai/Documents/Projects/WeatherJS/node_modules/express/lib/router/layer.js:95:5)
at trim_prefix (/Users/nimrodshai/Documents/Projects/WeatherJS/node_modules/express/lib/router/index.js:317:13)
at /Users/nimrodshai/Documents/Projects/WeatherJS/node_modules/express/lib/router/index.js:284:7
at Function.process_params (/Users/nimrodshai/Documents/Projects/WeatherJS/node_modules/express/lib/router/index.js:335:12)
at next (/Users/nimrodshai/Documents/Projects/WeatherJS/node_modules/express/lib/router/index.js:275:10)
Appreciate your help
Got it.
I wasn't aware that I should declare this variable the same way.
This is how I did it:
<% var catURL; %>
And put it at the top of the html

Angular 4 error formating Date field in ISO format with DatePipe

In an angular 4 / nodejs application, I am retrieving the following date field from MongoDB:
"2018-06-14T03:00:00.000Z"
Here is my HTML:
<div *ngIf="this.Lacador.dataAssociacao">
<p style="margin-top: 10px" type="text"> <label style="font-weight: normal"> {{ this.Lacador.dataAssociacao | date:"dd/MM/yyyy" }} </label></p>
</div>
In the screen, the date is displayed (as per image), but I have an error in the console which messes with all the scripts of the page:
ERROR Error: InvalidPipeArgument: 'function Date() { [native code] }' for pipe 'DatePipe'
at invalidPipeArgumentError (common.es5.js:2610)
at DatePipe.webpackJsonp.../../../common/#angular/common.es5.js.DatePipe.transform (common.es5.js:3506)
at checkAndUpdatePureExpressionInline (core.es5.js:11665)
at checkAndUpdateNodeInline (core.es5.js:12370)
at checkAndUpdateNode (core.es5.js:12303)
at debugCheckAndUpdateNode (core.es5.js:13167)
at debugCheckRenderNodeFn (core.es5.js:13146)
at Object.eval [as updateRenderer] (LacadoresViewComponent.html:96)
at Object.debugUpdateRenderer [as updateRenderer] (core.es5.js:13131)
at checkAndUpdateView (core.es5.js:12275)
Date displayed correctly:
Any clues on why it throws an exception, even through it formats the field as I want?
Edit: Added a missing quote.

#html.partial Model Not Found

~/Views/PlanBuilder/PlanBuilder.cshtml
#{
ViewBag.Title = "PlanBuilder";
Layout = "~/Views/Shared/_LayoutPlanBuilder.cshtml";
}
<div id="tabs-1">
<div id="wrap" class="left">
<ul>
#Html.Partial("~/Views/Hall/Index.cshtml");
</ul>
</div>
</div>
~/Views/Hall/Index.cshtml
#model IEnumerable<ShaadiPlanner.Models.Hall>
#{
ViewBag.Title = "Index";
Layout = "~/Views/Shared/_LayoutPlanBuilder.cshtml";
}
#foreach (var item in Model) <!-- ERROR LINE -->
{
<li id="#Html.DisplayFor(modelItem => item.ID)" class="options left">
<div class="box-header">
<h4 class="left"><span class="name">#Html.DisplayFor(modelItem => item.Name)</span> (#Html.DisplayFor(modelItem => item.Area))</h4>
<h4 class="right">Rs. <span class="price">#Html.DisplayFor(modelItem => item.EstCost)</span></h4>
</div>
</li>
}
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Note: When i define Model in the #Html.Partial code like this then #Html.Partial("~/Views/Hall/Index.cshtml", model); it give following error.
Compilation Error
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 'model' does not exist in the current context
Try uppercasing Model, i.e.
#Html.Partial("~/Views/Hall/Index.cshtml", Model);
As #webdeveloper comments, you have not got a model declared in your view!