erb comment vi plugin - plugins

I always use nerdcommenter to comment blocks in my code, and it works pretty well on almost all kinds of programming languages. However, I have been editing a lot of .html.erb files recently. When I comment
<%= text_field_tag 'sid',nil,:class=>"input-medium search-query" %>
after typing ,cb
I got the following result
<%#<%= text_field_tag 'sid',nil,:class=>"input-medium search-query" %>%>
what I want is
<%#= text_field_tag 'sid',nil,:class=>"input-medium search-query" %>
How do I make it work or are there any other good plugins for editing erb files under the vi editor.

Related

No <br> by default in tinymce

i've tried many things I've found here on stack, but none seem to help with the
<p> text </p>
<br>
Problem.
What I'm asking is how to switch off by default the <br> making by tinymce.
I know shift-enter does the trick, but I have a user generated site, and having to edit each tinymce input... Well takes too much time.
Thanks.
Try to use
echo str_replace('<br>',' ',$variable_that_echoing);

locate missing html tags in emacs

How can I validate that all tags have been closed in emacs?
<div>
hi
<div id="2">
hello
<div>
The above being a very simple example of a missing div. How can i see in emacs which html tag is missing?
If it is XHTML, nxml-mode can validate it automatically. That's what I am using. (I.e. I switch to nxml-mode for validation, though I usually use html-mode.)

encoding problems on site.master page (asp.net mvc2) on production server (2003 with IIS 6)

I have a site that uses the Hebrew language.
All the pages looks great, expect from the text that is generated in site.master.
This text comes a gibberish.
This is from master page:
<ul id="menu">
<li>
<%: Html.ActionLink("לקוחות", "List", "Customers")%></li>
same code from any other page shows hebrew chars.
The result is either gibberish, or encoded gibberish:
<div id="title">
<h1>
îòøëú ðéäåì ùéáåõ èëðàéí</h1>
</div>
<div id="menucontainer">
<ul id="menu">
<li>
ì÷åçåú</li>
tried to switch encoding in the browser but nothing gets me back to Hebrew.
This happens ONLY on production server, on my Dev machine (win7) it works fine.
The views inside the master pages shows OK also on production.
Any ideas ?
My advice would be: ditch the IIS 6 and use IIS Express, which you can install on most old OS's. It does introduce another technology into the question but this technology is newer, easy to use, maintain and script and more suitable for this new range of web development technologies like MVC, etc.
So, if you have an option to select what you use and can make decisions about it, definitely go for it.
Alternatively, you can play around with server regional settings and stuff like that but you might end up losing lots of hours to this.

Stripped Down CKEditor Vs Markdown

I have been looking into why WYSIWYG editors are bad for content creation. The most common reason given is that they output incorrect html. But what if I use editors with reduced functionality?
My requirements are only the ability to italicize, make text bold, create ordered/unordered lists and (maybe at a later date) add inline images.
My users will hopefully be 'persistent' users (small numbers of laypersons using the app frequently)
In this context how do I choose between Markdown (WMD editor) & a stripped down WYSIWYG editor. How would page performance be affected with each? I consider fidelity & reproduciblity of data to be important.
You choose by considering your audience. Wiki markup and markdown is for geeks. Your customers sound like they're probably not geeks so I would suggest CKEditor or Twiki-style editor (good, simple Wysiwyg UI) for non-geek users.
Basic concern: Why force lay-people to learn a markup language when solid alternatives exist?
See the Custom Toolbar editor in this CKEditor demo. Or check out TinyMCE.
OK, I tested both.
Even for my basic formatting requirements, CKEditor generated quite ghastly html
Now this is the input
This actually appears to be better
I hope users understand what we are doing
Lets see
But in the meantime
CKEditor Output
<p> This actually appears to be better</p>
<p> I hope users understand what we are doing</p>
<p> Lets see</p>
<p> </p>
<p> But in the meantime</p>
And Markdown Output
<p>This actually appears to be better <br>
I hope users understand what we are doing <br>
Lets see</p>
<p>But in the meantime</p>
Now if this is the difference between these two for the most basic formatting (linebreaks and paragraphs), what will it be like in a 200 word submission. I think most users will need to know only this
For line breaks, two SPACES and hit ENTER.
For new paragraphs, hit ENTER twice
The rest of the stuff could be learnt incrementally
Is it that hard to engineer a 'basic' WYSIWYG editor?
EDIT
After adding these to config.js above problem is solved
config.enterMode = CKEDITOR.ENTER_BR;
config.shiftEnterMode = CKEDITOR.ENTER_P;

htmlencode TinyMce/textarea to sql MVC 2 .net 4

I am creating a simple ‘site news’ feature on an MVC 2 .net 4 web site. The site news articles are kept in a simple sql data base, actually I’m doing it with Entity Framework Code First and compact sql, consisting of colums articleID, articleDate articleSummary and articleDetail (model.ItemEntry in code below). The articleDetail is a textarea that I would like to edit with TinyMce or some other WYSIWYG editors if you have alternate editors to suggest or recommend please do so and why.
I’m looking for a way to have the text in the articleDetail enterd by TinyMce by way of the textarea, which may contain html as well as text, htmlencoded as it’s recorded into rows of the table. Seems to me that would be a likely configuration option, I haven’t found it. And that by htmlencoding the textarea would bypass all the difficulties I’ve encountered while attempting to save the TinyMce/textarea data to sql.
Although I will use this live it’s mainly a learning experience. And I’m a bit stubborn on wanting to learn how to do this. Otherwise I would just use the textarea and skip the WYSIWYG for this simple application.
While attempting to compose simple text using TinyyMce I’ve run into the problem of .net 4 and requestvalidation. It appears that I would have to relax my security by placing <httpRuntime requestValidationMode="2.0" /> in the web config and add [ValidateInput(false)] to my controllers create post action. I don’t want to relax the security that .net 4 is providing, kinda stuck now as to how to strip the html from the TinyMce/textarea.
At this point it occurred to me that what I really wanted to do was htmlencode the text as it could be valuable to have some html formatting in the articleDetail. Blog posts and other applications save information in sql that will somehow eventually be html, how do they do it?
In Summary (some of) my questions are
Are there any WYSIWYG editors that htmlencode their content? That way I could have htmlencoded html news articles stored in sql. I’ll then be attempting to htmldecode that for display when news articles are displayed.
alternately
How might I just simplify strip the html from the TinyMce/textarea before I save to sql?
Is relaxing to requestValidationMode="2.0" my only solution?
Research resources I’ve found helpful in this learning experience.
Ack! couldn't post 'em as this is my first post. Gee I thought I read the FAQ and was being a good Nerditquette kinda guy. Incidently I composed this in Live writer and it's posted here on my blog including the links I had researched and found helpful.
Some relevant pieces of source code.
Create.aspx
<script type="text/javascript">
tinyMCE.init({
mode: "textareas",
theme: "simple"
});
<div class="editor-label">
<%: Html.LabelFor(model => model.ItemEntry) %>
</div>
<div class="editor-field">
<%: Html.TextAreaFor(model => model.ItemEntry) %>
<%: Html.ValidationMessageFor(model => model.ItemEntry) %>
</div>
NewsController.cs
// POST: /News/Create
[HttpPost]
// [ValidateInput(false)]
public ActionResult Create(Item item)
{
if (ModelState.IsValid)
{
siteNews.Items.Add(item);
siteNews.SaveChanges();
return RedirectToAction("Index");
}
return View(item);
}
Why would you want to htmlEncode your content just to save it in the database? It's a useless step.
Why do you want to strip the html if you're using a rich text editor? If just want text, stay with a textarea. You can configure tinyMCE to use bbtags but I would only use that for users who can't be trusted.
Setting your requestValidationMode to 2.0 is how you can allow your code to save html. There is nothing wrong with that.