class Jekyll::PayPalEWP
Public Class Methods
new(tag_name, variables, tokens)
click to toggle source
Calls superclass method
# File lib/jekyllEWP.rb, line 168 def initialize(tag_name, variables, tokens) super @variables = variables.split(" ") @buttonpurpose = @variables[0] unless @variables[1].nil? @separatesubmitbutton = getBool(@variables[1]) else @separatesubmitbutton = false end unless @variables[2].nil? if @separatesubmitbutton == true #is an id @formid = @variables[2] else #is an image @buttonimage = @variables[2] end else #no value provided if @separatesubmitbutton == true #is an id @formid = 0 else #is an image @buttonimage = "https://www.paypalobjects.com/en_US/i/btn/btn_cart_LG.gif" #some arbitrary thing end end end
Public Instance Methods
lookup(context, name)
click to toggle source
Lookup allows access to the page/post variables through the tag context
blog.sverrirs.com/2016/04/custom-jekyll-tags.html
# File lib/jekyllEWP.rb, line 208 def lookup(context, name) lookup = context name.split(".").each { |value| lookup = lookup[value] } lookup end
render(context)
click to toggle source
# File lib/jekyllEWP.rb, line 214 def render(context) wrapInForm( getButtonEncryptionValue( getButtonOptionsString( "#{lookup(context, 'site.paypal_cert_id')}", getButtonCmd(@buttonpurpose), "#{lookup(context, 'site.paypal_email_address')}", "#{lookup(context, 'page.name')}", #product name "#{lookup(context, 'page.price')}"), #product price #"#{lookup(context, 'page.sku')}" #product identifier ENV['EWP_PRIVKEY'], ENV['EWP_PUBCERT'], ENV['EWP_PAYPAL_PUBCERT'], ENV['EWP_PRIVKEY_PASS']), "#{lookup(context, 'site.paypal_sandbox_mode')}", @separatesubmitbutton, @buttonimage, @formid) end