Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

try to convert to peg.js reality

  • Loading branch information...
commit 3c4e7f91b2533279910eaa1f5bf6fb92d2a46206 1 parent b62198c
@Almad Almad authored
View
4 curl.html
@@ -2,7 +2,7 @@
<p class="ioDesc">Request</p>
<pre class="incoming"><code class="language-bash">curl --include<% if @headers: %><% for header,value of @headers: %> --header <%= @helpers.escape "#{header}: #{value}" %><% end %> \
<% end %><% if @method isnt 'GET' or @body: %> --request <%= @method %> \
- <% end %><%if @method isnt 'GET' and (@contentType is "text/html" or @contentType is "text/plain"): %> --data "<%= ((@helpers.escape line)[1..-2] + "\n" for line in @body).join('')[0..-2] %>" \
- <% else if @body: %> --data <%= @helpers.escape @body.join("") %> \
+ <% end %><%if @method isnt 'GET' and (@contentType is "text/html" or @contentType is "text/plain"): %> --data "<%= ((@helpers.escape line)[1..-2] + "\n" for line in @body)[0..-2] %>" \
+ <% else if @body: %> --data <%= @helpers.escape @body %> \
<% end %>"<%= @apiUrl %><%= @url %>"</code></pre>
</section>
View
4 javascript.html
@@ -10,7 +10,7 @@
alert('Status: '+this.status+'\nHeaders: '+JSON.stringify(this.getAllResponseHeaders())+'\nBody: '+this.responseText);
}
};
-xhr.send(<%= @helpers.escape @body.join("\n") %>);</code></pre>
+xhr.send(<%= @helpers.escape @body %>);</code></pre>
<pre class="jsRunCode" style="display: none">
var xhr = new XMLHttpRequest();
xhr.open('<%= @method.toUpperCase() %>', '<%= @apiUrl %><%= @url %>');
@@ -27,6 +27,6 @@
}
}
};
-xhr.send(<%= @helpers.escape @body.join("\n") %>);
+xhr.send(<%= @helpers.escape @body %>);
</pre>
</section>
View
2  nodejs.html
@@ -6,7 +6,7 @@
<% else : %>
request({
url: "<%= @apiUrl %><%= @url %>",<% if @body: %>
- body: <%= @helpers.escape @body.join("\n") %>,<% end %><% if @helpers.isNotEmpty @headers: %>
+ body: <%= @helpers.escape @body %>,<% end %><% if @helpers.isNotEmpty @headers: %>
headers: {<%= ("#{@helpers.escape header}: #{@helpers.escape value}" for header,value of @headers).join(", ") %>}, <% end %>
method: "<%= @method.toUpperCase() %>"
}, function (error, response, body) {
View
2  php.html
@@ -12,7 +12,7 @@
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "<%= @method %>");
<% end %><% if @method isnt 'GET' and (@contentType is "text/html" or @contentType is "text/plain"): %>
$fields = <%= eos %><%= "#{line}\n" for line in @body %>EOT;
-curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);<% else if @body and @body.length > 0: %>curl_setopt($ch, CURLOPT_POSTFIELDS, <%= @helpers.escape @body.join('') %>);<% end %>
+curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);<% else if @body and @body.length > 0: %>curl_setopt($ch, CURLOPT_POSTFIELDS, <%= @helpers.escape @body %>);<% end %>
<% if @headers and @helpers.isNotEmpty(@headers): %>curl_setopt($ch, CURLOPT_HTTPHEADER, array(<% for header, value of @headers: %><% if headerFirst: %><% headerFirst = false %><% else: %>, <% end %><%= @helpers.escape "#{header}: #{value}" %><% end %>));
<% end %>$response = curl_exec($ch);
curl_close($ch);
View
8 python.html
@@ -4,10 +4,10 @@
<% if @contentType is "application/json": %>from json import dumps
<% else if @contentType is "application/x-www-form-urlencoded": %>from urllib import urlencode
<% end %>
-<% if @contentType is "application/x-www-form-urlencoded": %>values = urlencode(<%= @body.join('') %>)
-<% else if @contentType is "application/json": %>values = dumps(<%= @body.join('') %>)
-<% else if @method isnt 'GET' and (@contentType is "text/html" or @contentType is "text/plain"): %>values = <%= @helpers.escape @body.join("\n") %>
-<% else if @method isnt 'GET': %>values = <%= @helpers.escape @body.join('') %>
+<% if @contentType is "application/x-www-form-urlencoded": %>values = urlencode(<%= @body %>)
+<% else if @contentType is "application/json": %>values = dumps(<%= @body %>)
+<% else if @method isnt 'GET' and (@contentType is "text/html" or @contentType is "text/plain"): %>values = <%= @helpers.escape @body %>
+<% else if @method isnt 'GET': %>values = <%= @helpers.escape @body %>
<% end %><% if @helpers.isNotEmpty @headers: %>headers = {<%= ("#{@helpers.escape header}: #{@helpers.escape value}" for header,value of @headers).join(", ") %>}
<% end %>request = Request("<%= @apiUrl %><%= @url %>"<% if @method in ['POST', 'PUT'] : %>, data=values<% end %><% if @helpers.isNotEmpty @headers: %>, headers=headers<% end %>)
<% if @method not in ['GET', 'POST'] : %>request.get_method = lambda: '<%= @method %>'
View
2  raw.html
@@ -1,5 +1,5 @@
<section name="raw" class="raw">
<p class="ioDesc">Request</p>
<pre class="incoming"><code><%= "#{header}: #{value}\n" for header, value of @headers %></code></pre>
- <pre class="incoming"><code class="<%= @helpers.getContentTypeBrush @headers %>"><%= @body.join("\n") %></code></pre>
+ <pre class="incoming"><code class="<%= @helpers.getContentTypeBrush @headers %>"><%= @body %></code></pre>
</section>
View
12 ruby.html
@@ -2,11 +2,11 @@
<p class="ioDesc">Request</p>
<pre class="incoming"><code class="language-ruby">require 'rubygems'
require 'rest_client'
-<% if @body and @contentType is "application/x-www-form-urlencoded": %>values = CGI::escape(<%= @helpers.escape @body.join('') %>)
-<% else if @body and @contentType is "application/json": %>values = <%= @helpers.escape @body.join('') %>
-<% else if @method isnt 'GET' and (@contentType is "text/html" or @contentType is "text/plain"): %>values = <%= @helpers.escape @body.join("\n") %>
-<% else if @body and @body.join(''): %>values = <%= @helpers.escape @body.join('') %>
-<% end %><% if @helpers.isNotEmpty @headers: %>headers = {<%= [':'+@helpers.rubyKey header+' => '+@helpers.escape value for header,value of @headers].join(", ") %>}
-<% end %>response = RestClient.<%= @method.toLowerCase() %> "<%= @apiUrl %><%= @url %>"<% if @body and @body.join(''): %>, values<% end %><% if @helpers.isNotEmpty @headers: %>, headers<% end %>
+<% if @body and @contentType is "application/x-www-form-urlencoded": %>values = CGI::escape(<%= @helpers.escape @body %>)
+<% else if @body and @contentType is "application/json": %>values = <%= @helpers.escape @body %>
+<% else if @method isnt 'GET' and (@contentType is "text/html" or @contentType is "text/plain"): %>values = <%= @helpers.escape @body %>
+<% else if @body and @body: %>values = <%= @helpers.escape @body %>
+<% end %><% if @helpers.isNotEmpty @headers: %>headers = {<%= [':'+@helpers.rubyKey header+' => '+@helpers.escape value for header,value of @headers] %>}
+<% end %>response = RestClient.<%= @method.toLowerCase() %> "<%= @apiUrl %><%= @url %>"<% if @body: %>, values<% end %><% if @helpers.isNotEmpty @headers: %>, headers<% end %>
puts response</code></pre>
</section>
Please sign in to comment.
Something went wrong with that request. Please try again.