I stored some html contents in a local resource file.
So it has html tags in it such as p, br, div, etc.
I used GetLocalResourceObject("myContent")
to display the content on the page,
but the page doesnt render it as HTML.
It turned out that I overlooked the htmlhelper syntax.
I used <%= %> instead of <%: %>
Related
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.
I have a .html.erb page and I am trying to comment something out using traditional HTML comments:
<!--
User Id (testing MySQL call): <%= #User.uid %>
-->
But since its a Ruby reference that I am commenting out, it isn't getting commented, and is generating ruby errors. How could I comment out such a thing? I also tried putting a # before that line, but that didn't work either.
In your ERB tags, to do a comment, use:
<%-# #User.uid %>
You'll still need the HTML comment tags wrapping the other text too.
You can comment out an ERB expression by changing the <%= into a <%#. This will not hide the HTML containing it from view, but you can combine HTML comments with the ERB comment to keep your application from throwing an error and hiding the surrounding HTML bits.
<!--
User Id (testing MySQL call): <%# #User.uid %>
-->
You can also comment a block with =begin and =end like this:
<%
=begin %>
<%= link_to "Sign up now!", signup_path, :class => "signup_button round" %>
<%
=end %>
I'm trying to wrap content with some static HTML in MVC and I'm not having any luck figuring this out. There must be an obvious solution that I'm not seeing, as this would seem like a desired feature.
In my View, I need to wrap HTML content with something:
<uc1:mc>
<p>Hello World!</p>
</uc1:mc>
That will render like:
<div class="ribbon">
<div class="left"></div>
<p>Hello World!</p>
<div class="right"></div>
</div>
With a Template like:
<div class="ribbon">
<div class="left"></div>
<%= IncomingMarkupGoesHere %>
<div class="right"></div>
</div>
The idea is to reuse html that wraps around other html.
I'm currently using two User Controls to achieve this, one with everything before and the other with everything after. Something like this:
<% Html.RenderPartial("RightRibbon_Start"); %>
Target Content...
<% Html.RenderPartial("RightRibbon_End"); %>
But this seems sloppy and isn't conducive to passing parameters that apply to HTML before and after the target content.
It's important that the content to be wrapped be allow to be written as multiple lined markup and not just a string, otherwise I would just pass the content as the Model.
What about creating helpers and passing the HTML in as an argument?
Passing html markup into an ASP.NET User Control
How do I display the image in a view?
The documentation says:
<%= image_tag formatted_photo_path(#photo, :jpg) %>
This is not what I want.
I just want to display an image on a view I don't care about the url.
E.g., Avatar.
Do I need to write a path to the directory or is a method already made?
/public/images/avatar/id
Thank you
Does the example above not render something like this to the view?
<img src="/path-to-generated-image.jpg"/>