fxbois / web-mode

web template editing mode for emacs
https://web-mode.org
GNU General Public License v3.0
1.64k stars 260 forks source link

Indentation issue with .ejs #396

Closed steckerhalter closed 9 years ago

steckerhalter commented 9 years ago
<% if (post.excerpt && index){ %>
    <%- post.excerpt %>
    <p class="article-more-link">
        <a href="<%- url_for(post.path) %>#more"><%= __('more') %></a>
    </p>
    <% } else { %>
    <%- post.content %>
    <% } %>

in this exampe the if block indentation is wrong. this is probably because JS is not considered for indentation? would that be hard to add?

fxbois commented 9 years ago

@steckerhalter could you test the last version on github please

steckerhalter commented 9 years ago

the block above is ok now, I tried another template, which gave me another problem:

  <%
  var title = page.title;

  if (is_archive()){
                    title = 'Archives';

                    if (is_month()){
                                    title += ': ' + page.year + '/' + page.month;
                                    } else if (is_year()){
                                                          title += ': ' + page.year;
                                                          }
                    } else if (is_category()){
                                              title = 'Category: ' + page.category;
                                              } else if (is_tag()){
                                                                   title = 'Tag: ' + page.tag;
                                                                   }
  %>

sorry...

fxbois commented 9 years ago

@steckerhalter I am in an airport ... I've pushed a patch but am not sure of the result

steckerhalter commented 9 years ago

have a good flight then :)

it's not yet working. here's the whole template:

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <%
  var title = page.title;

  if (is_archive()){
    title = 'Archives';

    if (is_month()){
      title += ': ' + page.year + '/' + page.month;
    } else if (is_year()){
      title += ': ' + page.year;
    }
  } else if (is_category()){
    title = 'Category: ' + page.category;
  } else if (is_tag()){
    title = 'Tag: ' + page.tag;
  }
  %>
  <title><% if (title){ %><%= title %> | <% } %><%= config.title %></title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <%- open_graph({twitter_id: theme.twitter, google_plus: theme.google_plus, fb_admins: theme.fb_admins, fb_app_id: theme.fb_app_id}) %>
  <% if (theme.rss){ %>
    <link rel="alternative" href="<%- theme.rss %>" title="<%= config.title %>" type="application/atom+xml">
  <% } %>
  <% if (theme.favicon){ %>
    <link rel="icon" href="<%- theme.favicon %>">
  <% } %>
  <link href='https://fonts.googleapis.com/css?family=Arapey:400,400italic|Gudea:400,400italic,700' rel='stylesheet' type='text/css'>
  <%- css('css/style') %>
</head>
  <body>
    <%- body %>
    <script type="text/javascript">
      var _paq = _paq || [];
      _paq.push(['trackPageView']);
      _paq.push(['enableLinkTracking']);
      (function() {
        var u="<%= config.piwik_url %>";
        _paq.push(['setTrackerUrl', u+'piwik.php']);
        _paq.push(['setSiteId', 1]);
        var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
        g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
      })();
    </script>
    <noscript><p><img src="<%= config.piwik_url %>piwik.php?idsite=1" style="border:0;" alt="" /></p></noscript>
  </body>
</html>

more .ejs template to try are here: https://github.com/hexojs/hexo-theme-landscape/tree/master/layout

fxbois commented 9 years ago

@steckerhalter I ve pushed an other patch ... your example works without an issue on my machine

steckerhalter commented 9 years ago

ok, for some reason I had to restart emacs to make the changes apply. works very well now. thanks a lot! :beers: