CARVIEW |
Select Language
HTTP/2 302
server: nginx
date: Tue, 05 Aug 2025 13:52:36 GMT
content-type: text/plain; charset=utf-8
content-length: 0
x-archive-redirect-reason: found capture at 20090103212402
location: https://web.archive.org/web/20090103212402/https://github.com/why/markaby/tree
server-timing: captures_list;dur=1.023741, exclusion.robots;dur=0.032775, exclusion.robots.policy;dur=0.014313, esindex;dur=0.017313, cdx.remote;dur=84.048757, LoadShardBlock;dur=857.711961, PetaboxLoader3.resolve;dur=400.910692, PetaboxLoader3.datanode;dur=105.277248
x-app-server: wwwb-app215
x-ts: 302
x-tr: 985
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=0
set-cookie: wb-p-SERVER=wwwb-app215; path=/
x-location: All
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
HTTP/2 301
server: nginx
date: Tue, 05 Aug 2025 13:52:37 GMT
content-type: text/html; charset=utf-8
content-length: 107
x-archive-orig-server: nginx/0.6.31
x-archive-orig-date: Sat, 03 Jan 2009 21:24:02 GMT
x-archive-orig-connection: close
x-archive-orig-status: 301 Moved Permanently
location: https://web.archive.org/web/20090103212402/https://github.com/why/markaby/tree/master
x-archive-orig-x-runtime: 310ms
x-archive-orig-cache-control: no-cache
x-archive-orig-content-length: 107
cache-control: max-age=1800
memento-datetime: Sat, 03 Jan 2009 21:24:02 GMT
link: ; rel="original", ; rel="timemap"; type="application/link-format", ; rel="timegate", ; rel="first memento"; datetime="Thu, 04 Dec 2008 17:21:25 GMT", ; rel="prev memento"; datetime="Thu, 04 Dec 2008 17:21:25 GMT", ; rel="memento"; datetime="Sat, 03 Jan 2009 21:24:02 GMT", ; rel="next memento"; datetime="Mon, 08 Jun 2009 19:13:43 GMT", ; rel="last memento"; datetime="Mon, 08 Jun 2009 19:13:43 GMT"
content-security-policy: default-src 'self' 'unsafe-eval' 'unsafe-inline' data: blob: archive.org web.archive.org web-static.archive.org wayback-api.archive.org athena.archive.org analytics.archive.org pragma.archivelab.org wwwb-events.archive.org
x-archive-src: 52_7_20090103190611_crawl102-c/52_7_20090103212348_crawl103.arc.gz
server-timing: captures_list;dur=0.807432, exclusion.robots;dur=0.062952, exclusion.robots.policy;dur=0.044132, esindex;dur=0.013411, cdx.remote;dur=25.019715, LoadShardBlock;dur=193.044024, PetaboxLoader3.datanode;dur=214.154297, load_resource;dur=240.955258, PetaboxLoader3.resolve;dur=147.124488
x-app-server: wwwb-app215
x-ts: 301
x-tr: 496
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=0
x-location: All
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
HTTP/2 200
server: nginx
date: Tue, 05 Aug 2025 13:52:38 GMT
content-type: text/html; charset=utf-8
x-archive-orig-server: nginx/0.6.31
x-archive-orig-date: Sat, 03 Jan 2009 21:24:02 GMT
x-archive-orig-connection: close
x-archive-orig-status: 200 OK
x-archive-orig-x-runtime: 120ms
x-archive-orig-etag: "cfa577db4800f78b981e742010690427"
x-archive-orig-cache-control: private, max-age=0, must-revalidate
x-archive-orig-content-length: 22655
x-archive-guessed-content-type: text/html
x-archive-guessed-charset: utf-8
memento-datetime: Sat, 03 Jan 2009 21:24:02 GMT
link: ; rel="original", ; rel="timemap"; type="application/link-format", ; rel="timegate", ; rel="first memento"; datetime="Mon, 15 Sep 2008 04:27:18 GMT", ; rel="prev memento"; datetime="Mon, 15 Sep 2008 04:27:18 GMT", ; rel="memento"; datetime="Sat, 03 Jan 2009 21:24:02 GMT", ; rel="next memento"; datetime="Mon, 05 Jan 2009 07:58:57 GMT", ; rel="last memento"; datetime="Sat, 17 Aug 2024 07:45:40 GMT"
content-security-policy: default-src 'self' 'unsafe-eval' 'unsafe-inline' data: blob: archive.org web.archive.org web-static.archive.org wayback-api.archive.org athena.archive.org analytics.archive.org pragma.archivelab.org wwwb-events.archive.org
x-archive-src: 52_7_20090103190611_crawl102-c/52_7_20090103212348_crawl103.arc.gz
server-timing: captures_list;dur=0.668090, exclusion.robots;dur=0.048704, exclusion.robots.policy;dur=0.012258, esindex;dur=0.012698, cdx.remote;dur=436.182395, LoadShardBlock;dur=501.357486, PetaboxLoader3.datanode;dur=519.838143, load_resource;dur=291.951649, PetaboxLoader3.resolve;dur=253.037151
x-app-server: wwwb-app215
x-ts: 200
x-tr: 1303
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=0
x-location: All
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
content-encoding: gzip
why's markaby at master — GitHub
We got nominated! Help us out and vote for GitHub as Best Bootstrapped Startup of 2008. (You can vote once a day.) [ hide ]
This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (

This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (

Description: | markup as ruby |
Homepage: | https://code.whytheluckystiff.net/markaby/ |
Clone URL: |
git://github.com/why/markaby.git
Give this clone URL to anyone.
git clone git://github.com/why/markaby.git
|

Bryan Stearns (author)
Fri Mar 07 12:49:49 -0800 2008
markaby /
name | age | message | |
---|---|---|---|
![]() |
CHANGELOG | Mon Feb 05 11:35:51 -0800 2007 | * CHANGELOG: changes so far [tim] |
![]() |
README | Sat Nov 24 13:51:15 -0800 2007 | littleears - just testing [Kelly Felkins] |
![]() |
Rakefile | Tue Dec 05 14:47:29 -0800 2006 | * lib/markaby/rails.rb: make flash work [tim] |
![]() |
init.rb | Sun Feb 04 10:07:32 -0800 2007 | * lib/markaby/rails.rb: give helpers access to... [tim] |
![]() |
lib/ | Fri Mar 07 12:49:49 -0800 2008 | Add support for framesets, ticket #59 [Bryan Stearns] |
![]() |
setup.rb | Tue Jan 17 13:00:38 -0800 2006 | setup.rb: allow traditional installation. [why] |
![]() |
test/ | Fri Mar 07 12:49:49 -0800 2008 | Add support for framesets, ticket #59 [Bryan Stearns] |
![]() |
tools/ | Sun Dec 17 06:35:51 -0800 2006 | * tools/rakehelp.rb: reverting previous change [tim] |
README
= Markaby (Markup as Ruby) Markaby is a very short bit of code for writing HTML pages in pure Ruby. It is an alternative to ERb which weaves the two languages together. Also a replacement for templating languages which use primitive languages that blend with HTML. == Using Markaby as a Rails plugin Write Rails templates in pure Ruby. Example layout: html do head do title 'Products: ' + action_name stylesheet_link_tag 'scaffold' end body do p flash[:notice], :style => "color: green" self << content_for_layout end end == Using Markaby as a Ruby class Markaby is flaming easy to call from your Ruby classes. require 'markaby' mab = Markaby::Builder.new mab.html do head { title "Boats.com" } body do h1 "Boats.com has great deals" ul do li "$49 for a canoe" li "$39 for a raft" li "$29 for a huge boot that floats and can fit 5 people" end end end puts mab.to_s Markaby::Builder.new does take two arguments for passing in variables and a helper object. You can also affix the block right on to the class. See Markaby::Builder for all of that. = A Note About <tt>instance_eval</tt> The Markaby::Builder class is different from the normal Builder class, since it uses <tt>instance_eval</tt> when running blocks. This cleans up the appearance of the Markaby code you write. If <tt>instance_eval</tt> was not used, the code would look like this: mab = Markaby::Builder.new mab.html do mab.head { mab.title "Boats.com" } mab.body do mab.h1 "Boats.com has great deals" end end puts mab.to_s So, the advantage is the cleanliness of your code. The disadvantage is that the block will run inside the Markaby::Builder object's scope. This means that inside these blocks, <tt>self</tt> will be your Markaby::Builder object. When you use instance variables in these blocks, they will be instance variables of the Markaby::Builder object. This doesn't affect Rails users, but when used in regular Ruby code, it can be a bit disorienting. You are recommended to put your Markaby code in a module where it won't mix with anything. = The Six Steps of Markaby If you dive right into Markaby, it'll probably make good sense, but you're likely to run into a few kinks. Why not review these six steps and commit them memory so you can really *know* what you're doing? == 1. Element Classes Element classes may be added by hooking methods onto container elements: div.entry do h2.entryTitle 'Son of WebPage' div.entrySection %{by Anthony} div.entryContent 'Okay, once again, the idea here is ...' end Which results in: <div class="entry"> <h2 class="entryTitle">Son of WebPage</h2> <div class="entrySection">by Anthony</div> <div class="entryContent">Okay, once again, the idea here is ...</div> </div> == 2. Element IDs IDs may be added by the use of bang methods: div.page! { div.content! { h1 "A Short Short Saintly Dog" } } Which results in: <div id="page"> <div id="content"> <h1>A Short Short Saintly Dog</h1> </div> </div> == 3. Validate Your XHTML 1.0 Output If you'd like Markaby to help you assemble valid XHTML documents, you can use the <tt>xhtml_transitional</tt> or <tt>xhtml_strict</tt> methods in place of the normal <tt>html</tt> tag. xhtml_strict do head { ... } body { ... } end This will add the XML instruction and the doctype tag to your document. Also, a character set meta tag will be placed inside your <tt>head</tt> tag. Now, since Markaby knows which doctype you're using, it checks a big list of valid tags and attributes before printing anything. >> div :styl => "padding: 10px" do >> img :src => "samorost.jpg" >> end InvalidHtmlError: no such attribute `styl' Markaby will also make sure you don't use the same element ID twice! == 4. Escape or No Escape? Markaby uses a simple convention for escaping stuff: if a string is an argument, it gets escaped. If the string is in a block, it doesn't. This is handy if you're using something like RedCloth or RDoc inside an element. Pass the string back through the block and it'll skip out of escaping. div.comment { RedCloth.new(str).to_html } But, if we have some raw text that needs escaping, pass it in as an argument: div.comment raw_str One caveat: if you have other tags inside a block, the string passed back will be ignored. div.comment { div.author "_why" div.says "Torpedoooooes!" "<div>Silence.</div>" } The final div above won't appear in the output. You can't mix tag modes like that, friend. == 5. Auto-stringification If you end up using any of your Markaby "tags" as a string, the tag won't be output. It'll be up to you to add the new string back into the HTML output. This means if you call <tt>to_s</tt>, you'll get a string back. div.title { "Rock Bottom" + span(" by Robert Wyatt").to_s } But, when you're adding strings in Ruby, <tt>to_s</tt> happens automatically. div.title { "Rock Bottom" + span(" by Robert Wyatt") } Interpolation works fine. div.title { "Rock Bottom #{span(" by Robert Wyatt")}" } And any other operation you might perform on a string. div.menu! \ ['5.gets', 'bits', 'cult', 'inspect', '-h'].map do |category| link_to category end. join( " | " ) == 6. The <tt>tag!</tt> Method If you need to force a tag at any time, call <tt>tag!</tt> with the tag name followed by the possible arguments and block. The CssProxy won't work with this technique. tag! :select, :id => "country_list" do countries.each do |country| tag! :option, country end end = A Note About Rails Helpers When used in Rails templates, the Rails helper object is passed into Markaby::Builder. When you call helper methods inside Markaby, the output from those methods will be output to the stream. This is incredibly handy, since most Rails helpers output HTML tags. head do javascript_include_tag 'prototype' autodiscovery_link_tag end However, some methods are designed to give back a String which you can use elsewhere. That's okay! Every method returns a Fragment object, which can be used as a string. p { "Total is: #{number_to_human_size @file_bytes}" } Also see the Quick Tour above, specifically the stuff about auto-stringification. If for any reason you have trouble with fragments, you can just call the <tt>@helpers</tt> object with the method and you'll get the String back and nothing will be output. p { "Total is: #{@helpers.number_to_human_size @file_bytes}" } Conversely, you may call instance variables from your controller by using a method and its value will be returned, nothing will be output. # Inside imaginary ProductController def list @products = Product.find :all end # Inside app/views/product/list.mab products.each do |product| p product.title end = Credits Markaby is a work of immense hope by Tim Fletcher and why the lucky stiff. Thankyou for giving it a whirl. Markaby is inspired by the HTML library within cgi.rb. Hopefully it will turn around and take some cues.
This feature is coming soon. Sit tight!