I've noticed a strange thing in the Visual Studio 2010 Prosessional (in the ASP.NET MVC 3 project). If I have the syntax like below, the compiler doesn't checks if there is any error inside.
<% foreach (var item in Model) { %>
<div class="author-box">
<div class="author-box-header">
<%: Html.ActionLink(item.Name, "", new { id = item.AuthorID }) %>
</div>
<div class="author-box-body">
Books: <%: Html.DisplayFor(o => item.Books.Count) %>
// Here's the error, shoutld be item.Book.Count
</div>
</div>
<% } %>
Only when I open that .aspx page by myself in the solution, then the compiler validates the code.
So, how to force the compiler to automatically chcecks the syntax
while compilating the project ?
You can when you compile your views. Here is a post about that.
Here is the tutorial on how to do it, which was accepted as answer
From the community wiki post:
after your build your solution to compile it, your will see that your
view will be compiled too.
NOTE to test it, break some code on one of your view on purpose and
try to build. you will see that you'll get an error message
So doing that means: break a view; break the build. Which seems like what you want
Related
I'm wondering if there is a way to add syntax highlighting for JavaScript code inside of Underscore.js templates in Atom editor? I've searched for some plugins for that, but with no result.
I have a number of HTML files with Underscore.js templates inside of HTML, and the code looks like this:
<div>
<% lists.forEach(list => { %>
<span id="list-<%= list.id %>"><%= list.name %></span>
<% }); %>
</div>
So maybe there are some plugins that I've missed? Thanks in advance.
Try changing grammar to Html (Ruby - ERB). Edit -> Select Grammar
I'm trying to display content from one wiki page in redmine in my welcome/index file.
I've tried linking pages with [[foo]] (which I have found out only works in the wiki itself) and !{{include(projectname:stuff)}}, but when I try to use this, my redmine only displays it as plain text.
<div class="splitcontentright">
<div class="news box">
<h3><%=("News")%></h3>
!{{include(MyWikiPage:MyArticle))}}
<%= call_hook(:view_welcome_index_right, :projects => #projects) %>
</div>
</div>
Is this the wrong method? Is there another way to achieve what I'm trying to do?
After skimming trough redmines code I found the solution.
Instead of writing
!{{include(MyWikiPage:MyArticle)}}
you'll have to write:
<%= textilizable "{{include(Project:Article)}}" %>
this calls the textilizable function which let's you use wiki macros from wherever you want.
In Middleman, I am trying to set up a blog site, using custom layout for the blog. My problem is that the main layout is loading, but the blog layout for my articles is not. The article files are being served in with their plain body.
In source/layouts/ I have two files: layout.erb and article_layout.erb.
My intent is to use article_layout.erb for my blog articles.
In config.rb I have the following:
activate :blog do |blog|
blog.sources = "articles/{category}/{year}-{month}-{day}-{title}.html"
blog.layout = "article_layout"
end
I have also tried moving article_layout.erb to source/articles/ as well as prepending the config.rb file like this: blog.layout = "layouts/article_layout"
Another failed approach is to comment out the above option and configure the layout by adding this line instead: page "/articles/*", layout: "article_layout".
So far none of these approach show a difference. Since the default layout is not being rendered I would expect some sort of error message if the path to the layout cannot be found, but nothing shows up.
I managed to replicate your problem with my own Middleman blog setup.
The docs are unclear on this because there is a broken link in the layout section of Blogging.
You need to use the nested layout feature of Middleman and wrap your custom layout in:
<% wrap_layout :layout do %>
<% end %>
So your article_layout.erb would look something like this:
<% wrap_layout :layout do %>
<div class="article-container">
<article>
<h2 class="article-title"><%= current_page.title %></h2>
<%= yield %>
</article>
</div>
<% end %>
And keep your custom layout in the source/layouts folder.
Here are the docs for Nested Layouts for your reference.
I hope this helps.
This question is proving hard to google, so if there is a duplicate question & answer or definitive reference, please share.
<% %> An embedded code block is server code that executes during the page's render phase. The code in the block can execute programming statements and call functions in the current page class. http://msdn2.microsoft.com/en-gb/library/ms178135(vs.80).aspx
<%= %> most useful for displaying single pieces of information. http://msdn2.microsoft.com/en-us/library/6dwsdcf5(VS.71).aspx
<%# %> Data Binding Expression Syntax. http://msdn2.microsoft.com/en-us/library/bda9bbfx.aspx
<%$ %> ASP.NET Expression. http://msdn2.microsoft.com/en-us/library/d5bd1tad.aspx
<%# %> Directive Syntax. http://msdn2.microsoft.com/en-us/library/xz702w3e(VS.80).aspx
<%-- --%> Server-Side Comments. http://msdn2.microsoft.com/en-US/library/4acf8afk.aspx
<%: %> Like <%= %> But HtmlEncodes the output (new with Asp.Net 4). http://weblogs.asp.net/scottgu/archive/2010/04/06/new-lt-gt-syntax-for-html-encoding-output-in-asp-net-4-and-asp-net-mvc-2.aspx
It is actually described pretty well in msdn.
Check out following link:
http://msdn.microsoft.com/en-us/library/fy30at8h(v=vs.71).aspx
I am using facebox to get some information in a popup window.
I have got facebox.js and facebox.css file in my assets folder. I have included this code in my application.js file
jQuery(document).ready(function($) {
$('a[rel*=facebox]').facebox()
});
I have link_to which looks like this <%=link_to "Create",new_activities_path, :rel => "facebox" %>
When I click on the create link I get a popup which is empty and does not render the form which is in the partial.
I am able to render this partial without facebox. I have been looking all over the net but it seems the documentation of facebox is not that good.
Can anyone guide me?
Thanks,
Was able to do it by tweaking the code little bit :-
now my link_to looks like this <%=link_to "Create",new_activity_path, :remote => true %>
I also have a new action in the controller and a corresponding new.js.erb file which has got the below mentioned code:-
$.facebox('<%= escape_javascript(render :partial => 'new') %>')
the code in the application.js remains the same. I am able to render the partial in _new.html.erb in a nice popup.
Hope it will be useful to others as the documentation of facebox is very poor.
Thanks,