Class: Php

Inherits:
Object show all
Defined in:
lib/xiki/php.rb

Class Method Summary collapse

Class Method Details

.runObject



2
3
4
5
6
7
8
9
10
11
12
13
# File 'lib/xiki/php.rb', line 2

def self.run
  # Get block contents
  txt, left, right = View.txt_per_prefix #:prefix=>Keys.prefix

  result = self.run_internal txt
  # Insert result at end of block
  orig = Location.new
  View.cursor = right
  Line.to_left
  View.insert result.gsub(/^/, '  ')+"\n"
  orig.go
end

.run_internal(txt) ⇒ Object



15
16
17
18
19
20
# File 'lib/xiki/php.rb', line 15

def self.run_internal txt
  # Write to temp file
  File.open("/tmp/tmp.php", "w") { |f| f << "<?\n#{txt}\n?>\n" }
  # Call js
  Console.run "php -f /tmp/tmp.php", :sync=>true
end