ERB Ruby Templates -- Online Editor - ruby

I am aware of quite a few different JavaScript based online text editors for WYSISYG html editing, however I am trying to find something similar for ERB Ruby templates. Essentially it would be just like the other editors, however it would not garble or encode the <%= foo.to_s %> type code blocks.
Is there anything out there which will be capable of this? I am willing to try and modify and existing JS editor if there is nothing already, so any suggestions as to which one is the nicest to work with would be much appreciated.
Thanks
Amar

You can use the ProtectedSource configuration option in CKeditor for this purpose:
FCKConfig.ProtectedSource.Add( /<%[\s\S]*?%>/g ) ;

Related

Localized partials in Middleman

In Middleman, is it possible to localize partials? I haven't been able to find any documentation for this. But I'm working on long pieces with complex markup, and it may be necessary to adjust the templates themselves for localization. I'd like to be able to narrow these sections down to partials so that I don't have to fall back on maintaining entirely separate templates when this happens. Is there a place I can put partials such that the partial command will look up a partial as partial_name.language.html.erb?
It might also be possible to dynamically construct partials argument if it's possible to tell what language I'm in within the ERb. So I could do something like <%= partial "my_piece/partials/#{current_lang}/tricky_section" %>, but I don't know if something like current_lang exists.
On the issue tracker, I found documentation of how I can use the second option I can do <%= partial "partials/my_piece/#{lang}/tricky_section" %>, or directly embed logic that otherwise keys off of lang.

Passing Markdown Content to Ruby Function With Jekyll/Liquid

I am trying to write a jekyll plugin that will take a normal markdown file and provide some extra functionality on top of it. In particular, I need to do some (not actually) fancy things with tables. I know you can write straight HTML into a markdown file, but there is a requirement that the content folks don't want to / can't edit HTML.
As an extra wrench in the works, the mobile layout has a UX requirement that I essentially have to render the table as a group of divs as opposed to a table.
My initial thought was to pass the {{page.content}} variable to a ruby function extending Liquid::Tag. From there I was planning on parsing the markdown file and either:
1. If normal non-table markdown, use as normal
2. If table markdown, look for custom identifier in markdown, do what needs to be done (e.g. add class, etc)
If I do something like this:
def render(context)
content = Liquid::Template.parse(#markup).render context
end
It renders the context as a normal markdown file. However, I want to break up the context variable and work with the pieces before rendering. I've tried a few different approaches that I've gotten from the jekyll docs and Stack Overflow and gotten nowhere.
Does anyone have any experience with this? I am heading down the right path? For what it's worth, Ruby/Jekyll/Liquid is fairly new to me, so if you think I may have missed something fairly basic and obvious then please let me know.
A markdown table tool for editors !
markdownify your table in http://www.tablesgenerator.com/markdown_tables
paste the markdown result in http://prose.io/
done
I don't know other way to simplify editor's work on Jekyll, but I'll be very interested in earing from your project. Good luck.

CKEditor with HTML content stores, displays but cannot display for edit

I have used CKEditor for a few years without really understanding it. I now want to use it to display text which will include HTML, CSS, JavaScript and PHP example code. None of that needs to execute it is just to show the code to others.
Currently I used the textarea replace method to edit content and I need to carry on that way. When I add the content first time it is sanitised (mysqli_real_escape_string) and stored in a MySQL database correctly. It also then displays correctly with the CKEditor markup working as markup and the HTML/PHP showing as a code example. However, when I edit the content a second time the HTML examples become "real" HTML and are no longer visible as examples.
For example this:
<?php echo "hello"; ?>
<p>Hello</p>
is correctly (?) stored as:
<p><?php echo "me"; ?></p>
<p><p>Hello</p></p>
and displays on the page as shown in the first code snippet (which is what I want). When I then hit edit again the code examples vanish into the background as real HTML (part of the page). If I put the code examples in as code snippets (which I would rather not have to do because of the intended users) the result in the editor (second edit) looks like this:
<!--?php echo "me"; ?-->
Hello
I am sure i am missing a basic understanding of what is going on behind the scenes but can anyone explain how to allow users to type in text which includes HTML, CSS, JavaScript, PHP and MySQL code examples which must then appear as examples and not markup (and be editable as examples).
I have played with config.entities and config.protectedSource after some research but they do not seem to be relevant (or to work). Weirdly a couple of times it seemed to work fine and I thought I had cracked it but then stopped with no further changes to the config. That means I now have less idea what I am doing than when I started!
You don't mention which version you are using, but if it's relatively new (4.4+) you can use the Code Snippets plugin that was designed exactly for this. See the demo at http://ckeditor.com/demo#widgets. It might help with the encoding issues too. There's docs on it too.
Th help with the current encoding issue, it would help a LOT if you showed us how you output the data and load it into CKEditor. For example "When I then hit edit again" doesn't really describe anything without context. For example, do you use setData() with AJAX? Do you use an inline editor? Code examples would be the best.

HTML in public folder with hooks

I have an HTML file (index.html) in the public folder.
These HTML has some "hooks" in it.
Like:
<div>{client_ssnumber}</div>
<div>{client_company}</div>
I have to retrieve this file and complete the information in the hooks using data obtained in a controllerĀ“s method, then display in the screen.
What is the rails way to do it?
You can't do this (without terrible terrible hacking), it's hard coded to look for public files before checking the router.
Anyway, Your client is wrong. Tell them to use "<%= ... %>" instead of "{ ... }" and move it into a view (you should move it into the view, so it's where you want it to be, then just tell them what the name of the file is).
There is no sensible reason to make up your own templating language. It will be buggier and slower, and it will add a lot of time to get the product out the door. Plus you'll then have to maintain that code. This is a solved problem, use ERB. If they really like that syntax, use Mustache which is pretty similar, and is an existing templating language.
If you can't get them to do this, you have much bigger problems than how to render this page.
Put them in a view, on app/views/ and use a template engine like erb or haml. You can then assign variables in a controller and use them in your view.

Separate Content for each different language in joomla

It is possible to get multiple input textareas where I can enter content for each language separately. Is there some kind of extension that enables this. I am a novice at joomla so please help me.
Well, something like
Title(English): <THEN A TEXT BOX HERE>
Title(Other Langauge): <THEN A TEXT BOX HERE>
Content(English):
<THEN A TEXTAREA HERE>
Content(Other Language)
<THEN ANOTHER TEXTAREA HERE>
I am just passing ideas. May be there is something better that can solve my problem. basically, i need to manually enter different content for every language installed. Not through automatic translation. It is not even available...
Have a look at Joomla Translations Manager - we use it on all our multilingual pages and it will help you translate JText::_() strings
As JackJoe said, Joomfish is what you are looking for. http://www.joomfish.net/

Resources