Answer the question
In order to leave comments, you need to log in
How to specify jsdoc for this in templates (underscore)?
Hello!
I'm trying to make it sane to display underscore templates in the PhpStorm IDE. To highlight the <% ..js here.. %> tags, I found the ejs plugin, it has a similar syntax, so it works. (If you know better - let me know, because it does not suit me 100%).
Next, I try to specify the types of variables that are passed to the template, as well as what this is for this template.
I'm trying like this:
<%
/** @this Jii.view.WebView this */
/** @typedef {String} myvar */
%>
<% this.registerJsFile('http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js'); %>
<% this.registerCss('body {background: #eee;}'); %>
<% this.registerJs('console.log(6626)', 'head'); %>
<div>
<%= myvar %>
</div>
Answer the question
In order to leave comments, you need to log in
So far I've only solved it this way:
<%
/** @typedef {String} qqq */
/** @this {Jii.view.WebView} */
(function() {
%>
<% this.registerCssFile('http://api.jquery.com/jquery-wp-content/themes/jquery/css/base.css'); %>
<% this.registerJsFile('http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js'); %>
<% this.registerCss('body {background: #eee;}'); %>
<% this.registerLinkTag({
rel: 'icon',
type: 'image/x-icon',
href: 'https://assets-cdn.github.com/favicon.ico'
}); %>
<% this.registerMetaTag({
authenticity_token: 'csrf-param'
}); %>
<div>
<%= qqq %>
</div>
<% })(); %>
The obvious solution is to call this variable something else, like that
or self
.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question