I am looking for a nice way to change the visibility of an HTML div.
The probably most common way to do this, is by using JavaScript, since it can manipulate my DOM. In my current project, I prefer not to use any JavaScript, so here is my question:
Is there another way to solve this, by using technologies like Ruby or Sass?
I am using in my project Ruby + the Sinatra Framework, as well as Haml and Sass.
I am not sure with HAML syntax. Whether the below fit for you need?
- if hide_div?
%div {:style=> "display:none;"}
- else
%div {:style=> "display:block;"}
- end
Related
Is there a way to use sass/scss with Dojotoolkit ?
I've searched for any documentation, tutorial or references but couldn't find any.
It depends on what you really need to do.
Generally Dojo Themes like Claro are based on LESS CSS preprocessor, Dojo Flat instead use Stylus.
So if you need to modify or fork Dojo Themes you should stick to LESS or Stylus.
If instead you do not need to modify a Dojo Themes and just simply need add your CSS for anything else you could use with no problem SCSS/SASS.
I would suggest in that case to process your styles using a separate "tasks", example you could use gulp-sass or similar.
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.
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.
Given a HTML structure like this
<strong>My Link</strong>
is not caught by Capybara through a cucumber step
When I follow "My Link"
using a default webstep
When /^(?:|I )follow "([^"]*)"$/ do |link|
click_link(link)
end
while this works:
When I follow "<strong>My Link</strong>"
I haven't been using Capbybara for long, but I can see what causes the problem. So, on a more general level — what's the proper way to go about this? Surely this case has to be pretty common, right?
Any ideas and general musings about Cucumber abuse very welcome!
I would move strong tag outside anchor tag or better use CSS for that.
Or you can assign id attribute to link and use it instead of content. This way is the best if your app supports multiple languages.
Otherwise you have to write some sort of xpath selector for such special case:
find(:xpath, "//a[contains(//text(), \"#{locator}\")]").click
Not tested, just an idea.
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 ) ;