GVKun编程网logo

ES6 Template Strings (转)

36

最近很多小伙伴都在问ES6TemplateStrings(转)这两个问题,那么本篇文章就来给大家详细解答一下,同时本文还将给你拓展Anerrorhappenedduringtemplateparsin

最近很多小伙伴都在问ES6 Template Strings (转)这两个问题,那么本篇文章就来给大家详细解答一下,同时本文还将给你拓展An error happened during template parsing (template: "class path resource [templates/index.h...、An error happened during template parsing (template: "class path resource [templates/user.html]、Angular 学习系列 - - $templateCache 和 $templateRequest、com.intellij.psi.templateLanguages.TemplateDataLanguageMappings的实例源码等相关知识,下面开始了哦!

本文目录一览:

ES6 Template Strings (转)

ES6 Template Strings (转)

转自:https://developers.google.com/web/updates/2015/01/ES6-Template-Strings

Strings in JavaScript have been historically limited, lacking the capabilities one might expect coming from languages like Python or Ruby. ES6 Template Strings (available in Chrome 41+), fundamentally change that. They introduce a way to define strings with domain-specific languages (DSLs), bringing better:

  • String interpolation
  • Embedded expressions
  • Multiline strings without hacks
  • String formatting
  • String tagging for safe HTML escaping, localization and more.

Rather than stuffing yet another feature into Strings as we know them today, Template Strings introduce a completely different way of solving these problems.

Syntax

Template Strings use back-ticks (``) rather than the single or double quotes we''re used to with regular strings. A template string could thus be written as follows:

 
var greeting = `Yo World!`;

So far, Template Strings haven''t given us anything more than normal strings do. Let’s change that.

String Substitution

One of their first real benefits is string substitution. Substitution allows us to take any valid JavaScript expression (including say, the addition of variables) and inside a Template Literal, the result will be output as part of the same string.

Template Strings can contain placeholders for string substitution using the ${ } syntax, as demonstrated below:

 
// Simple string substitution
var name = "Brendan";
console.log(`Yo, ${name}!`);

// => "Yo, Brendan!"

As all string substitutions in Template Strings are JavaScript expressions, we can substitute a lot more than variable names. For example, below we can use expression interpolation to embed for some readable inline math:

 
var a = 10;
var b = 10;
console.log(`JavaScript first appeared ${a+b} years ago. Crazy!`);

//=> JavaScript first appeared 20 years ago. Crazy!

console.log(`The number of JS MVC frameworks is ${2 * (a + b)} and not ${10 * (a + b)}.`);
//=> The number of JS frameworks is 40 and not 200.

They are also very useful for functions inside expressions:

 
function fn() { return "I am a result. Rarr"; }
console.log(`foo ${fn()} bar`);
//=> foo I am a result. Rarr bar.

The ${} works fine with any kind of expression, including member expressions and method calls:

 
var user = {name: ''Caitlin Potter''};
console.log(`Thanks for getting this into V8, ${user.name.toUpperCase()}.`);

// => "Thanks for getting this into V8, CAITLIN POTTER";

// And another example
var thing = ''drugs'';
console.log(`Say no to ${thing}. Although if you''re talking to ${thing} you may already be on ${thing}.`);

// => Say no to drugs. Although if you''re talking to drugs you may already be on drugs.

If you require backticks inside of your string, it can be escaped using the backslash character \ as follows:

 
var greeting = `\`Yo\` World!`;

Multiline Strings

Multiline strings in JavaScript have required hacky workarounds for some time. Current solutions for them require that strings either exist on a single line or be split into multiline strings using a \ (blackslash) before each newline. For example:

 
var greeting = "Yo \
World";

Whilst this should work fine in most modern JavaScript engines, the behavior itself is still a bit of a hack. One can also use string concatenation to fake multiline support, but this equally leaves something to be desired:

 
var greeting = "Yo " +
"World";

Template Strings significantly simplify multiline strings. Simply include newlines where they are needed and BOOM. Here''s an example:

Any whitespace inside of the backtick syntax will also be considered part of the string.

 
console.log(`string text line 1
string text line 2`);

Tagged Templates

So far, we''ve looked at using Template Strings for string substitution and for creating multiline strings. Another powerful feature they bring is tagged templates. Tagged Templates transform a Template String by placing a function name before the template string. For example:

 
fn`Hello ${you}! You''re looking ${adjective} today!`

The semantics of a tagged template string are very different from those of a normal one. In essence, they are a special type of function call: the above "desugars" into

 
fn(["Hello ", "! You''re looking ", " today!"], you, adjective);
Note: Nicholas Zakas goes into more detail on the break-down of these arguments in the Template Strings section of his excellent book,  Understanding ES6.

Note how the (n + 1)th argument corresponds to the substitution that takes place between the nth and (n + 1)th entries in the string array. This can be useful for all sorts of things, but one of the most straightforward is automatic escaping of any interpolated variables.

For example, you could write a HTML-escaping function such that..

 
html`<p title="${title}">Hello ${you}!</p>`

returns a string with the appropriate variables substituted in, but with all HTML-unsafe characters replaced. Let’s do that. Our HTML-escaping function will take two arguments: a username and a comment. Both may contain HTML unsafe characters (namely '', ", <, >, and &). For example, if the username is "Domenic Denicola" and the comment is "& is a fun tag", we should output:

 
<b>Domenic Denicola says:</b> "&amp; is a fun tag"

Our tagged template solution could thus be written as follows:

 
// HTML Escape helper utility
var util = (function () {
  // Thanks to Andrea Giammarchi
  var
    reEscape = /[&<>''"]/g,
    reUnescape = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34);/g,
    oEscape = {
      ''&'': ''&amp;'',
      ''<'': ''&lt;'',
      ''>'': ''&gt;'',
      "''": ''&#39;'',
      ''"'': ''&quot;''
    },
    oUnescape = {
      ''&amp;'': ''&'',
      ''&#38;'': ''&'',
      ''&lt;'': ''<'',
      ''&#60;'': ''<'',
      ''&gt;'': ''>'',
      ''&#62;'': ''>'',
      ''&apos;'': "''",
      ''&#39;'': "''",
      ''&quot;'': ''"'',
      ''&#34;'': ''"''
    },
    fnEscape = function (m) {
      return oEscape[m];
    },
    fnUnescape = function (m) {
      return oUnescape[m];
    },
    replace = String.prototype.replace
  ;
  return (Object.freeze || Object)({
    escape: function escape(s) {
      return replace.call(s, reEscape, fnEscape);
    },
    unescape: function unescape(s) {
      return replace.call(s, reUnescape, fnUnescape);
    }
  });
}());

// Tagged template function
function html(pieces) {
    var result = pieces[0];
    var substitutions = [].slice.call(arguments, 1);
    for (var i = 0; i < substitutions.length; ++i) {
        result += util.escape(substitutions[i]) + pieces[i + 1];
    }

    return result;
}

var username = "Domenic Denicola";
var tag = "& is a fun tag";
console.log(html`<b>${username} says</b>: "${tag}"`);
//=> <b>Domenic Denicola says</b>: "&amp; is a fun tag"

Other possible uses include auto-escaping, formatting, localization and in general, more complex substitutions:

 
// Contextual auto-escaping
qsa`.${className}`;
safehtml`<a href="${url}?q=${query}" onclick="alert(''${message}'')" style="color: ${color}">${message}</a>`;

// Localization and formatting
l10n`Hello ${name}; you are visitor number ${visitor}:n! You have ${money}:c in your account!`

// Embedded HTML/XML
jsx`<a href="${url}">${text}</a>` // becomes React.DOM.a({ href: url }, text)

// DSLs for code execution
var childProcess = sh`ps ax | grep ${pid}`;

Summary

Template Strings are in Chrome 41 beta+, IE Tech Preview, Firefox 35+ and io.js. Practically speaking if you would like to use them in production today, they''re supported in major ES6 Transpilers, including Traceur and 6to5. Check out our Template Strings sample over on the Chrome samples repo if you''d like to try them out. You may also be interested in ES6 Equivalents in ES5, which demonstrates how to achieve some of the sugaring Template Strings bring using ES5 today.

Template Strings bring many important capabilities to JavaScript. These include better ways to do string & expression interpolation, multiline strings and the ability to create your own DSLs.

One of the most significant features they bring are tagged templates - a critical feature for authoring such DSLs. They receive the parts of a Template String as arguments and you can then decide how to use the strings and substitutions to determine the final output of your string.

An error happened during template parsing (template:

An error happened during template parsing (template: "class path resource [templates/index.h...

转自 https://blog.csdn.net/qq_41426326/article/details/88837112

在开发 springboot 的时候,进行 modelAndView 视图层映射的时候,一直出现 

An error happened during template parsing (template: "class path resource [templates/index.html]")

模板解析过程中发生错误 (模板:“类路径资源 [templates/index.html]”)

在向 index.html 映射的时候出现错误,小编在和其他程序员一样打开了百度开始搜索,有各种说法

1. 配置文件问题.(我重新看了一遍确定没有问题,但是还是错误)

spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.suffix=.html
spring.thymeleaf.servlet.content-type=text/html
spring.thymeleaf.encoding=utf-8
spring.thymeleaf.mode=LEGACYHTML5
spring.thymeleaf.cache=false
spring.mvc.static-path-pattern=/**
spring.resources.static-locations=classpath:/static/
2. 说是 @Controller 和 @RestController 功能不一样,将 @Controller 修改为 @RestController 在加上 @ResponseBody (依然无效)、

3. 说在映射的时候实体类没有 get 方法,为变量加上 get 就可以了(结果我本来就有 get 方法的)

4. 还有说在 pom.xml 文件下的 build 配置 (都不是这个错误的解决方案)

<resources>
<resource>
<directory>sre/main/resources</directory>
</resource>
</resources>
最后小编早上智商最高峰的时候发现了这个小小小问题

 

在这附上小编 index.html 的文件开头,就是因为加了

https: xmlns:https="http://www.w3.org/1999/xhtml"

xmlns:th="http://www.thymeleaf.org"
导致调用的时候原本要调用第二句话的代码调用了第一句代码中的方法发生错误,把第一句代码删除就可以了

小编总结了一下,一般系统出现以下错误

An error happened during template parsing (template: "class path resource [templates/index.html]")

大家可以去看看视图层,并不是 java 代码出现错误.

An error happened during template parsing (template: "class path resource [templates/user.html]

An error happened during template parsing (template: "class path resource [templates/user.html]

问题:

An error happened during template parsing (template: "class path resource [templates/user.html]")

 

 解决方法:

1.配置文件问题。根据问题描述,问题可能为想要去的地址路径错误。解决方法:修改路径。

 

 

 

 2.@RestController

@RestController相当于@Response + @Controller,作用是将return的字符串响应在界面上。

而@Controller作用是将return中的字符串拼接配置文件中的前后缀,形成一个html地址,最后在网页上指向这个地址界面。

 两者作用不同。

 

3.为变量加上get

实体类中可能没有getter and setter方法,加上。

或者可能是LomBok出问题了,重启或者刷新maven包可能可以解决。

 

4.xmlns冲突。可能同时设置了 “https: xmlns:https="http://www.w3.org/1999/xhtml" ”和 “xmlns:th="http://www.thymeleaf.org" ”。删去“https: xmlns:https="http://www.w3.org/1999/xhtml" ”即可。

 

5.(我的问题)进行select搜索时,数据库中没有id=“111”这个数据!所以导致页面跳转指向不明,导致错误TAT

 

高了,血压高了!!!

 

写代码须细心啊TAT

   

Angular 学习系列 - - $templateCache 和 $templateRequest

Angular 学习系列 - - $templateCache 和 $templateRequest

OSC 请你来轰趴啦!1028 苏州源创会,一起寻宝 AI 时代

$templateCache

第一次使用模板,它被加载到模板缓存中,以便快速检索。你可以直接将模板标签加载到缓存中,或者通过 $templateCache 服务。

通过 script 标签

<script type=”text/ng-template” id=”template.html”>

<p>This is the content of the template</p>

</script>

备注:script 标签模板不需要包含在文档头部。但他必须在 $rootElement 下,不然模板将会被忽略。

通过 $templateCache 服务:

<div ng-app="Demo" ng-controller="testCtrl as ctrl"><!--<div ng-include="''templateId.html''"></div>--><div ng-bind-html="ctrl.text"></div>
  </div>

(function () {
    angular.module("Demo", [])
    .run(["$templateCache",templateCache])
    .controller("testCtrl", ["$templateCache","$sce",testCtrl]);function templateCache($templateCache){
      $templateCache.put(''templateId.html''''<a>This is the content of the template</a>'');
    }function testCtrl($templateCache,$sce) {var tpl = $templateCache.get(''templateId.html'');
        tpl = $sce.trustAsHtml(tpl);this.text = tpl;
    };
  }());

在上面调用模板的代码中,可以使用 controller 里的代码调用缓存里的模板,但是需要注意的是,需要使用 $sce 转成受信任的 html 插入代码,所以这里需要注入 $sce 服务。而且这边不止可以使用 js 调用,也可以直接在 html 里标签里使用 ng-include 调用。

$templateRequest

$templateRequest 服务运行进行安全检测,然后使用 $http 下载被提供的模板,成功后,将内容存储在 $templateCache 里。如果 HTTP 请求失败或 HTTP 请求的响应数据是空的,将抛出个 $compile 错误(通过设置该函数的第二个参数为 true)。该注意的是,$templateCache 的内容是可信的,所以调用 $sce.getTrustedUrl (tpl) 是省略的,当 tpl 的类型是字符串并且 $templateCache 具有匹配的项。

使用:$templateRequest(tpl,[ignoreRequestError]);

tpl:字符串或者 TrustedResourceUrl,HTTP 请求 URL 的模板。

ignoreRequestError:boolean 值,当请求失败或模板为空时,是否忽略该异常。

使用代码:

(function () {
    angular.module("Demo", [])
    .run(["$templateCache",templateCache])
    .controller("testCtrl", ["$templateRequest","$sce",testCtrl]);function templateCache($templateCache){
      $templateCache.put(''templateId.html''''<a>This is the content of the template</a>'');
    }function testCtrl($templateRequest,$sce) {var vm = this;
        $templateRequest("templateId.html").then(function(html){
            vm.text = $sce.trustAsHtml(html);
        })
    };
  }());

com.intellij.psi.templateLanguages.TemplateDataLanguageMappings的实例源码

com.intellij.psi.templateLanguages.TemplateDataLanguageMappings的实例源码

项目:bamboo-soy    文件:SoylayeredHighlighter.java   
public SoylayeredHighlighter(
    @Nullable Project project,@Nullable VirtualFile virtualFile,@NotNull EditorColoRSScheme colors) {
  // Creating main Highlighter.
  super(new SoySyntaxHighlighter(),colors);

  // Highlighter for the outer language.
  FileType type = null;
  if (project == null || virtualFile == null) {
    type = StdFileTypes.PLAIN_TEXT;
  } else {
    Language language = TemplateDataLanguageMappings.getInstance(project).getMapping(virtualFile);
    if (language != null) type = language.getAssociatedFileType();
    if (type == null) type = SoyLanguage.getDefaultTemplateLang();
  }

  SyntaxHighlighter outerHighlighter =
      SyntaxHighlighterFactory.getSyntaxHighlighter(type,project,virtualFile);

  registerLayer(OTHER,new LayerDescriptor(outerHighlighter,""));
}
项目:rythm_plugin    文件:RythmFileType.java   
private static LanguageFileType getAssociatedFileType(VirtualFile file,Project project) {
    if (project == null) {
        return null;
    }
    Language language = TemplateDataLanguageMappings.getInstance(project).getMapping(file);

    LanguageFileType associatedFileType = null;
    if (language != null) {
        associatedFileType = language.getAssociatedFileType();
    }

    if (language == null || associatedFileType == null) {
        associatedFileType = RythmLanguage.getDefaultTemplateLang();
    }
    return associatedFileType;
}
项目:GoJetPlugin    文件:JetFileType.java   
private static LanguageFileType getAssociatedFileType(VirtualFile file,Project project) {
    if (project == null) {
        return null;
    }
    Language language = TemplateDataLanguageMappings.getInstance(project).getMapping(file);

    LanguageFileType associatedFileType = null;
    if (language != null) {
        associatedFileType = language.getAssociatedFileType();
    }

    if (language == null || associatedFileType == null) {
        associatedFileType = JetLanguage.getDefaultTemplateLang();
    }
    return associatedFileType;
}
项目:GoJetPlugin    文件:JetlayeredSyntaxHighlighter.java   
public JetlayeredSyntaxHighlighter(Project project,EditorColoRSScheme scheme,FileType ptype,VirtualFile virtualFile) {
    super(new JetSyntaxHighlighter(),scheme);

    // Highlighter for outer ide
    FileType type = null;
    if (project == null || virtualFile == null) {
        type = StdFileTypes.PLAIN_TEXT;
    } else {
        Language language = TemplateDataLanguageMappings.getInstance(project).getMapping(virtualFile);
        if (language != null) type = language.getAssociatedFileType();
        if (type == null) type = JetLanguage.getDefaultTemplateLang();
    }

    SyntaxHighlighter outerHighlighter = SyntaxHighlighterFactory.getSyntaxHighlighter(type,virtualFile);
    registerLayer(TEXT,""));
}
项目:idea-doT    文件:DottemplateHighlighter.java   
public DottemplateHighlighter(@Nullable Project project,@NotNull EditorColoRSScheme colors) {
    // create main Highlighter
    super(new DotHighlighter(),colors);

    // Highlighter for outer lang
    FileType type = null;
    if(project == null || virtualFile == null) {
        type = StdFileTypes.PLAIN_TEXT;
    } else {
        Language language = TemplateDataLanguageMappings.getInstance(project).getMapping(virtualFile);
        if(language != null) type = language.getAssociatedFileType();
        if(type == null) type = DotLanguage.getDefaultTemplateLang();
    }
    @SuppressWarnings ("deprecation") // deprecated in IDEA 12,still needed in IDEA 11 Todo remove when IDEA 11 support is dropped
            SyntaxHighlighter outerHighlighter = SyntaxHighlighter.PROVIDER.create(type,virtualFile);

    registerLayer(DottokenTypes.CONTENT,""));
}
项目:idea-doT    文件:DotFileType.java   
private LanguageFileType getAssociatedFileType(VirtualFile file,Project project) {
    if (project == null) {
        return null;
    }
    Language language = TemplateDataLanguageMappings.getInstance(project).getMapping(file);

    LanguageFileType associatedFileType = null;
    if (language != null) {
        associatedFileType = language.getAssociatedFileType();
    }

    if (language == null || associatedFileType == null) {
        associatedFileType = DotLanguage.getDefaultTemplateLang();
    }
    return associatedFileType;
}
项目:Intellij-Dust    文件:DustlayeredSyntaxHighlighter.java   
public DustlayeredSyntaxHighlighter(@Nullable Project project,@NotNull EditorColoRSScheme colors) {
  // create main Highlighter
  super(new DustSyntaxHighlighter(),colors);

  // Highlighter for outer lang
  FileType type = null;
  if(project == null || virtualFile == null) {
    type = StdFileTypes.PLAIN_TEXT;
  } else {
    Language language = TemplateDataLanguageMappings.getInstance(project).getMapping(virtualFile);
    if(language != null) type = language.getAssociatedFileType();
    if(type == null) type = StdFileTypes.HTML;
  }
  SyntaxHighlighter outerHighlighter = SyntaxHighlighter.PROVIDER.create(type,virtualFile);

  registerLayer(DustTypes.HTML,""));
}
项目:rythm_plugin    文件:RythmlayeredSyntaxHighlighter.java   
public RythmlayeredSyntaxHighlighter(Project project,VirtualFile virtualFile) {
    super(new RythmSyntaxHighlighter(),scheme);

    FileType type = null;

    //Test for Java implementation
    FileType type1 = null;

    if (project == null || virtualFile == null) {
        type = StdFileTypes.PLAIN_TEXT;
    } else {
        Language language = TemplateDataLanguageMappings.getInstance(project).getMapping(virtualFile);
        if (language != null) type = language.getAssociatedFileType();
        if (type == null) {
            type = RythmLanguage.getDefaultTemplateLang();

            //Test for Java implementation
            //type1 = RythmLanguage.getLanguage();
        }

    }

    SyntaxHighlighter outerHighlighter = SyntaxHighlighterFactory.getSyntaxHighlighter(type,""));


    //Test for Java implementation
   /* SyntaxHighlighter middleHighlighter = SyntaxHighlighterFactory.getSyntaxHighlighter(type1,new LayerDescriptor(middleHighlighter,""));
   */

}
项目:GoJetPlugin    文件:JetFileViewProvider.java   
public JetFileViewProvider(PsiManager manager,VirtualFile file,boolean physical) {
    super(manager,file,physical);

    Language dataLang = TemplateDataLanguageMappings.getInstance(manager.getProject()).getMapping(file);
    if (dataLang == null) dataLang = StdFileTypes.HTML.getLanguage();

    if (dataLang instanceof TemplateLanguage) {
        myTemplateDataLanguage = PlainTextLanguage.INSTANCE;
    } else {
        myTemplateDataLanguage = LanguageSubstitutors.INSTANCE.substituteLanguage(dataLang,manager.getProject());
    }
}
项目:intellij-ce-playground    文件:FileTypePatternDialog.java   
public FileTypePatternDialog(@Nullable String initialPatterns,FileType fileType,Language templateDataLanguage) {
  myPatternField.setText(initialPatterns);

  if (fileType instanceof TemplateLanguageFileType) {
    final DefaultComboBoxModel model = (DefaultComboBoxModel) myLanguageCombo.getModel();
    model.addElement(null);
    final List<Language> languages = TemplateDataLanguageMappings.getTemplateableLanguages();
    Collections.sort(languages,new Comparator<Language>() {
      @Override
      public int compare(final Language o1,final Language o2) {
        return o1.getID().compareto(o2.getID());
      }
    });
    for (Language language : languages) {
      model.addElement(language);
    }
    myLanguageCombo.setRenderer(new ListCellRendererWrapper() {
      @Override
      public void customize(JList list,Object value,int index,boolean selected,boolean hasFocus) {
        setText(value == null ? "" : ((Language) value).getdisplayName());
        if (value != null) {
          final FileType type = ((Language)value).getAssociatedFileType();
          if (type != null) {
            setIcon(type.getIcon());
          }
        }
      }
    });
    myLanguageCombo.setSelectedItem(templateDataLanguage);
  } else {
    myLanguageCombo.setVisible(false);
    myTemplateDataLanguageButton.setVisible(false);
  }
}
项目:tools-idea    文件:FileTypePatternDialog.java   
public FileTypePatternDialog(@Nullable String initialPatterns,boolean hasFocus) {
        setText(value == null ? "" : ((Language) value).getdisplayName());
        if (value != null) {
          final FileType type = ((Language)value).getAssociatedFileType();
          if (type != null) {
            setIcon(type.getIcon());
          }
        }
      }
    });
    myLanguageCombo.setSelectedItem(templateDataLanguage);
  } else {
    myLanguageCombo.setVisible(false);
    myTemplateDataLanguageButton.setVisible(false);
  }
}
项目:idea-doT    文件:DotFileViewProvider.java   
private Language getTemplateDataLanguage(PsiManager manager,VirtualFile file) {
    Language dataLang = TemplateDataLanguageMappings.getInstance(manager.getProject()).getMapping(file);
    if(dataLang == null) {
        dataLang = DotLanguage.getDefaultTemplateLang().getLanguage();
    }

    Language substituteLang = LanguageSubstitutors.INSTANCE.substituteLanguage(dataLang,manager.getProject());

    // only use a substituted language if it's templateable
    if (TemplateDataLanguageMappings.getTemplateableLanguages().contains(substituteLang)) {
        dataLang = substituteLang;
    }

    return dataLang;
}
项目:consulo    文件:FileTypePatternDialog.java   
public FileTypePatternDialog(@Nullable String initialPatterns,boolean hasFocus) {
        setText(value == null ? "" : ((Language) value).getdisplayName());
        if (value != null) {
          final FileType type = ((Language)value).getAssociatedFileType();
          if (type != null) {
            setIcon(type.getIcon());
          }
        }
      }
    });
    myLanguageCombo.setSelectedItem(templateDataLanguage);
  } else {
    myLanguageCombo.setVisible(false);
    myTemplateDataLanguageButton.setVisible(false);
  }
}
项目:consulo    文件:LightPlatformTestCase.java   
public static void doTearDown(@Nonnull final Project project,ApplicationStarter application,boolean checkForEditors) throws Exception {
  CodeStyleSettingsManager.getInstance(project).dropTemporarySettings();
  checkAllTimersAredisposed();
  UsefulTestCase.doPostponedFormatting(project);

  LookupManager lookupManager = LookupManager.getInstance(project);
  if (lookupManager != null) {
    lookupManager.hideActiveLookup();
  }
  ((StartupManagerImpl)StartupManager.getInstance(project)).prepareForNexttest();
  inspectionProfileManager.getInstance().deleteProfile(PROFILE);
  assertNotNull("Application components damaged",ProjectManager.getInstance());

  new WriteCommandAction.Simple(project) {
    @Override
    @requiredWriteAction
    protected void run() throws Throwable {
      if (ourSourceRoot != null) {
        try {
          final VirtualFile[] children = ourSourceRoot.getChildren();
          for (VirtualFile child : children) {
            child.delete(this);
          }
        }
        catch (IOException e) {
          //noinspection CallToprintstacktrace
          e.printstacktrace();
        }
      }
      EncodingManager encodingManager = EncodingManager.getInstance();
      if (encodingManager instanceof EncodingManagerImpl) ((EncodingManagerImpl)encodingManager).clearDocumentQueue();

      FileDocumentManager manager = FileDocumentManager.getInstance();

      ApplicationManager.getApplication().runWriteAction(EmptyRunnable.getInstance()); // Flush postponed formatting if any.
      manager.saveAllDocuments();
      if (manager instanceof FileDocumentManagerImpl) {
        ((FileDocumentManagerImpl)manager).dropAllUnsavedDocuments();
      }
    }
  }.execute().throwException();

  assertFalse(PsiManager.getInstance(project).isdisposed());
  if (!ourAssertionsInTestDetected) {
    if (IdeaLogger.ourErrorsOccurred != null) {
      throw IdeaLogger.ourErrorsOccurred;
    }
  }
  PsiDocumentManagerImpl documentManager = clearuncommittedDocuments(project);
  ((HintManagerImpl)HintManager.getInstance()).cleanup();

  UIUtil.invokeAndWaitIfNeeded(new Runnable() {
    @Override
    public void run() {
      ((UndoManagerImpl)UndoManager.getGlobalInstance()).dropHistoryInTests();
      ((UndoManagerImpl)UndoManager.getInstance(project)).dropHistoryInTests();

      UIUtil.dispatchAllInvocationEvents();
    }
  });

  TemplateDataLanguageMappings.getInstance(project).cleanupForNexttest();

  ProjectManagerEx.getInstanceEx().closeTestProject(project);
  //application.setDataProvider(null);
  ourTestCase = null;
  ((PsiManagerImpl)PsiManager.getInstance(project)).cleanupForNexttest();

  CompletionProgressIndicator.cleanupForNexttest();

  if (checkForEditors) {
    checkEditorsReleased();
  }
  if (isLight(project)) {
    // mark temporarily as disposed so that rogue component trying to access it will fail
    ((ProjectImpl)project).setTemporarilydisposed(true);
    documentManager.clearuncommittedDocuments();
  }
}
项目:consulo-apache-veLocity    文件:VtlFileViewProvider.java   
@NotNull
static Language getTemplateDataLanguage(@NotNull VirtualFile virtualFile,@NotNull Project project) {
    final Language language = TemplateDataLanguageMappings.getInstance(project).getMapping(virtualFile);
    return language == null ? getTemplateDataLanguageByExtention(virtualFile) : language;
}
项目:consulo-apache-veLocity    文件:Util.java   
static void mapTemplateDataLanguageFor(PsiFile file,Language dataLanguage) {
    TemplateDataLanguageMappings mappings = TemplateDataLanguageMappings.getInstance(file.getProject());
    mappings.setMapping(file.getViewProvider().getVirtualFile(),dataLanguage);
    Assert.assertSame(dataLanguage,mappings.getMapping(file.getViewProvider().getVirtualFile()));
}

我们今天的关于ES6 Template Strings (转)的分享就到这里,谢谢您的阅读,如果想了解更多关于An error happened during template parsing (template: "class path resource [templates/index.h...、An error happened during template parsing (template: "class path resource [templates/user.html]、Angular 学习系列 - - $templateCache 和 $templateRequest、com.intellij.psi.templateLanguages.TemplateDataLanguageMappings的实例源码的相关信息,可以在本站进行搜索。

本文标签: