How to mention a variable inside a jinja block - jinja2

I have a form in my html, I use flask_wtf to help with forms and make it easier, I'm trying to set a default value inside my input, but I cannot mention a variable inside a jinja block.
this code should help you understand what I mean:
{{form.username(class="hidden", type="text", value="{{application.username}}")}}

{{reject.username(class="hidden", type="text", value=application.username)}}
I removed the double parenthesis on application.username and also removed the quotations.
that fixed it.

Related

Putting a break in between three different strings

I have three variables that are strings. However they sit one on top of the other with no spacing. Is there any way to add what would be equivalent to a in the ts file and not the template. Or am I able to add multiple values to my angular component input and somehow break it up there? I am not certain on how to achieve this. Any guidance would be greatly appreciated.
.ts file
this.myContent= this.content.paragraph1 + this.content.paragraph2 + this.content.paragraph3;
.html file
<my-component [myContent]="myContent"></my-component>
maybe you can use inline template literal. So you could assign this.myContent like this
this.myContent = `${this.content.p1}\n${this.content.p2}\n${this.content.p3}`
I would suggest the following approach:
Make this.myContent an array, and put this.content.paragraph1, this.content.paragraph2 and so on in it.
Put an *ngIf on <my-component>, and only display it if the content array has elements in it.
Put a <p *ngFor="..."> element within <my-component>, and iterate through the content array.
This will display the paragraphs, and will break them up.

Can I add the pattern attribute to textarea?

I know that the textarea doesn't support the functionality of pattern, however if I set the pattern variable in html, its still present in the browser.
So I have to execute the pattern verification in js anyways, but is it OK for me to store the pattern in the pattern attribute? As opposed to data-pattern or something, for consistency with the input elements?
You should use data-* attributes for extra attributes and since textarea tag does not support the pattern attribute then adding it like adding value to div.
Hope this helps.
Custom attribute is suppose to have the data- prefix, so I recommend to use that or you could ran into issues when validating your code.
And what happens if such an attribute suddenly become a standard attribute?
More to read:
https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Using_data_attributes
https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes#data-*
https://www.w3.org/TR/2011/WD-html5-20110525/elements.html#embedding-custom-non-visible-data-with-the-data-attributes

AngularJS Directive once-style vs HTML global style attribute

Why would I use one over the other, except if I need to define the style from a function?
<div once-style="{width:50%;}"/>
once-style
<div style="width:50%;"/>
HTML Style Attribute
If i have a fixed style in an AngularJS application is there a reason to use one over the other?
I tried finding relevant information, i just found this which really didn't answer my question.
One time binding is native to Angular. Inside the curly braces prefix the expression with a double colon. For example:
{{::name}}

Adding more than one class

Is it bad thing if I add more than one class for one object. Let's say:
text
Don't ask me why, I just need it.
Thanks.
You can use multiple class names (a perfectly normal thing to do), but are only allowed one class attribute on your HTML element.
Do this instead:
text
Following on from RedFilters' answer you could of course extend your class selectors by using the angular ng-class attribute as follows:
text
The resulting html would then be:
text
Might come in useful to get around a tslint "line too long" error :-)
There's no need for two class statements, simply:
text
Now, in order to handle this in CSS you need to do this:
.paren.default{
}
...Whithout spaces between the two class selectors.
Cheers!

html elements text/hidden along with file should be submitted?

how to submit html elements text, hidden etc., along with file element?
While using multipart for file element, the other elements are not read, like request.getParameter("") gives me null for other text/hidden elements...
please help me in this with the solution...
Thanks.
Narban.
<form enctype="multipart/form-data"... definitely does what you want.
Ensure that your other elements are inside the same form as your file input, and ensure that you have set the name attribute on all input elements you want to submit.