web-mode icon indicating copy to clipboard operation
web-mode copied to clipboard

Feature request: engine variable comment that overrides web-mode-engines-alist

Open alex-lokk opened this issue 9 years ago • 1 comments

Right now web-mode-enable-engine-detection works only if no other engine detected.

E.g. I have a bunch of ".html" files. Most of them are acutally Django templates, but some of them are pure HTML, some are underscore templates.

I would like it to be Django templates by default, but switch to underscore when I specify manually:

{# -*- engine:underscore -*- #}
<script id="tree-node-template" type="text/html">
  <span class="name
               <% if (dynex_count > 0) { %>
                 has-exercises
                 <% if (!ADAPTIVITY_ENABLED) { %>
                   not-selectable
                 <% } %>
               <% } %>
               " data-path="<%= path %>"><%- name %></span>
  <% if (dynex_list.length) { %>
    <ul class="dynex-list">
      <% _.each(dynex_list, function(d){ %>
      …
…

My quick dirty fix is simply allowing local variable to override the engine. But it probably breaks behavior for some other cases, I'm not sure if it's appropriate.

             web-mode-engine (web-mode-engine-canonical-name web-mode-engine))
       )
 
-    (when (and (or (null web-mode-engine)
-                   (string= web-mode-engine "none"))
-               web-mode-enable-engine-detection)
+    (when web-mode-enable-engine-detection
       (web-mode-detect-engine))
 
     (web-mode-on-engine-setted)

alex-lokk avatar Jun 30 '17 15:06 alex-lokk

@highcat why don't you rely on the path off the templates (or of the projet) to force the engine ?

fxbois avatar Jul 09 '17 16:07 fxbois