github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

manveru / innate

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 79
    • 13
  • Source
  • Commits
  • Network (13)
  • Issues (0)
  • Downloads (0)
  • Wiki (1)
  • Graphs
  • Branch: master

click here to add a description

click here to add a homepage

  • Branches (2)
    • gh-pages
    • master ✓
  • Tags (0)
Sending Request…
Click here to lend your support to: innate and make a donation at www.pledgie.com ! Edit Pledgie Setup

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

The core of Ramaze — Read more

  cancel

http://ramaze.net

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

Add a spec for Etanni 
manveru (author)
Tue Feb 02 23:59:05 -0800 2010
commit  c48a6479d3571fa5a5d848338243bbaa0dc8de2d
tree    c96907264a03716939392ea514547f2edcca073f
parent  baa0dd871c1be54c10315867832b2671747965a2
innate / lib / innate / view / etanni.rb lib/innate/view/etanni.rb
100644 35 lines (30 sloc) 0.876 kb
edit raw blame history
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
module Innate
  module View
    module Etanni
      def self.call(action, string)
        etanni = View.compile(string){|str| Innate::Etanni.new(str) }
        html = etanni.result(action.binding, (action.view || action.method))
        return html, 'text/html'
      end
    end
  end
 
  class Etanni
    SEPARATOR = "E69t116A65n110N78i105S83e101P80a97R82a97T84o111R82"
    START = "\n_out_ << <<#{SEPARATOR}.chomp!\n"
    STOP = "\n#{SEPARATOR}\n"
    REPLACEMENT = "#{STOP}\\1#{START}"
 
    def initialize(template)
      @template = template
      compile
    end
 
    def compile
      temp = @template.dup
      temp.strip!
      temp.gsub!(/<\?r\s+(.*?)\s+\?>/m, REPLACEMENT)
      @compiled = "_out_ = [<<#{SEPARATOR}.chomp!]\n#{temp}#{STOP}_out_"
    end
 
    def result(binding, filename = '<Etanni>')
      eval(@compiled, binding, filename).join
    end
  end
end
 
Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server