Dynamically set ID in UnderscoreJS template generated using Jade - backbone.js

I'm using Jade to generate JST templates but I'm having trouble setting placeholder for the id field.
.somediv(id=<%= id %>)
...
Jade compiler throws an error for the above syntax
undefined:501
buf.push(attrs({ terse: true, 'id':(<%= id %>), "class": ('somediv')
Is there a way to do this?

Correct syntax for attributes seems to be:
.somediv(id=id)
...
But if you need id to be exactly <%= id %> then you have to quote it and use != for values that shouldn't be escaped
.somediv(id!="<%= id %>")
...

Related

is not a field of struct type hugolib.SiteInfo in

I tried adding a new property to my theme/partials/footer.html template, and adding that property to my /config.toml file, but I keep getting the error:
ERROR: 2017/07/09 template: theme/partials/footer.html:16:40: executing "theme/partials/footer.html" at <.Site.CopyrightStart...>: CopyrightStartYear is not a field of struct type *hugolib.SiteInfo in theme/partials/footer.html
Example from my partial template file:
<span>© {{.Site.copyrightStartYear}}</span>
The template engine in Hugo will look for all site params under the [Params] block in the config.toml file (must be a quoted string for this example). These can be referenced via the .Site.Params.<paramName> lookup in partial templates.
e.g.
# config.toml
...
[Params]
myParam = "weeee!"
...
And use it in your HTML fragment:
# somePartial.html
<span>{{ .Site.Params.myParam }}</span>
...

AngularJS expression with HTML is adding quotes?

I'm trying to echo the following HTML expression (got it from decoded jSON):
<ion-item>Dresses</ion-item></ion-item>
Using this:
<ion-item-group *ngFor="let category of categories"><ion-item-divider color="light">{{category.name}}</ion-item-divider>{{category.links}}</ion-item-group>
But the result is:
<ion-item-group><ion-item-divider color="light">Women Clothes</ion-item-divider><ion-item><a href="/category/latest-collection/women/dresses">Dresses</a></ion-item><ion-item></ion-item-group>
Any ideas? :-(

How to display infinity symbol in AngularJS

I want to conditionally display a value or an infinity symbol in my Web Page.
I wanted to do something like this ..
<td class="rs-table-text" ng-if="batch.est_completion_time ">{{batch.est_completion_time}}</td>
That is if batch.est_completion_time is not empty then display whatever is coming from json.
And the json looks like :
{
"batch_queue_name": "Batch Five",
"start_date": "05/01/2017 12:18 A.M.",
"end_date": "08/01/2017 03:37 A.M.",
"est_completion_time":"∞",
"completion_status": "42"
}
But it does not display the infinity symbol. Rather , it displays the ∞ text only.
How to achieve the same ?
In your controller, prepare the data as following :
$scope.est_completion_time = $sce.trustAsHtml(batch.est_completion_time);
In your HTML, you can display it as it is. Don't forget to add ng-bind-html in the outer DOM element.
Adding only ng-bind-html can do the job :
ng-bind-html="batch.est_completion_time"

ngTagsInput get and parse data from database

When I use ngTagsInput before send to database I do:
angular.toJson($scope.tags);
When I make get I receive something like this in my scope {{}}:
[{"text":"abc"},{"text":"cba"},{"text":"tag"}]
What can I do to show my tags like this:
abc, cba, tag
In the template:
<span ng-repeat="(key, value) in tags"><span ng-if="!$first">, </span><span>{{value.text}}</span></span>
Or with Underscore in code:
var str = _.pluck(list, 'text').join(', ')
Other options here: Show an aggregated list in angularjs

ng-admin file uploadInformation get entity id

In ng-admin edit view I need to change file upload url with id as below , but I don't know how to fetch id of selected entity in uploadInformation base url like {{entry.values.id}} , below is my code :
files.editionView()
.title('Edit File {{ entry.values.id }}({{ entry.values.filePath}})') // title() accepts a template string, which has access to the entry
.actions(['list', 'show', 'delete']) // choose which buttons appear in the top action bar. Show is disabled by default
.fields([
nga.field('id').label('id').editable(false),
nga.field('file', 'file').uploadInformation({ 'url': baseurl +"files/upload/{{entry.values.id}}"}),// fields() without arguments returns the list of fields. That way you can reuse fields from another view to avoid repetition
])
{{ entry.values.id }} - is an Angular expression and in this form should be used in HTML not in JavaScript.
I assume that entry is your $scope variable, hence you need to write something like this: ... .uploadInformation({ 'url': baseurl+ "files/upload/"+$scope.entry.values.id})
$scope.entry should be prepopulated in your controller's code

Resources