Repository: struts-site
Updated Branches:
  refs/heads/master 0d209d153 -> 7ccd3bea1


Uses plugin to fetch tag parameters


Project: http://git-wip-us.apache.org/repos/asf/struts-site/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts-site/commit/7ccd3bea
Tree: http://git-wip-us.apache.org/repos/asf/struts-site/tree/7ccd3bea
Diff: http://git-wip-us.apache.org/repos/asf/struts-site/diff/7ccd3bea

Branch: refs/heads/master
Commit: 7ccd3bea115ea605b572e13d0a1dceece49bb449
Parents: 0d209d1
Author: Lukasz Lenart <lukaszlen...@apache.org>
Authored: Thu Sep 21 21:37:07 2017 +0200
Committer: Lukasz Lenart <lukaszlen...@apache.org>
Committed: Thu Sep 21 21:37:07 2017 +0200

----------------------------------------------------------------------
 source/_plugins/tag_parameters.rb | 37 ++++++++++++++++++++++++++++++++++
 source/tag-developers/a-tag.md    | 22 ++++++++++----------
 2 files changed, 48 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/struts-site/blob/7ccd3bea/source/_plugins/tag_parameters.rb
----------------------------------------------------------------------
diff --git a/source/_plugins/tag_parameters.rb 
b/source/_plugins/tag_parameters.rb
new file mode 100644
index 0000000..048f86c
--- /dev/null
+++ b/source/_plugins/tag_parameters.rb
@@ -0,0 +1,37 @@
+require 'net/http'
+require 'uri'
+require 'cgi'
+
+module Jekyll
+
+  class TagParameters < Liquid::Tag
+
+    def initialize(tag_name, markup, tokens)
+      url = 
'https://raw.githubusercontent.com/apache/struts/master/core/src/site/resources/tags/'
 + markup
+
+      puts 'Fetching content of url: ' + url
+
+      if url =~ URI::regexp
+        @content = fetchContent(url)
+      else
+        raise 'Invalid URL passed to RemoteFileContent'
+      end
+
+      super
+    end
+
+    def render(context)
+      if @content
+        @content[/#{Regexp.escape('<!-- START SNIPPET: tagattributes 
-->')}(.*?)#{Regexp.escape('<!-- END SNIPPET: tagattributes -->')}/m, 1]
+      else
+        raise 'Something went wrong in TagParameters'
+      end
+    end
+
+    def fetchContent(url)
+      Net::HTTP.get(URI.parse(URI.encode(url.strip)))
+    end
+  end
+end
+
+Liquid::Template.register_tag('tag_parameters', Jekyll::TagParameters)
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/struts-site/blob/7ccd3bea/source/tag-developers/a-tag.md
----------------------------------------------------------------------
diff --git a/source/tag-developers/a-tag.md b/source/tag-developers/a-tag.md
index fceb87c..5aac77b 100644
--- a/source/tag-developers/a-tag.md
+++ b/source/tag-developers/a-tag.md
@@ -9,36 +9,36 @@ Please make sure you have read the [Tag 
Syntax](tag-syntax.html) document and un
 
 ## Description
 
-~~~~~~~
-{snippet:id=javadoc|javadoc=true|url=org.apache.struts2.components.Anchor}
-~~~~~~~
-
+A tag that creates a HTML `<a>.` This tag supports the same attributes as the 
`url` tag, including nested parameters 
+using the `param` tag.
+ 
 > While this tag can be used with the [simple theme](simple-theme.html), 
 > [xhtml theme](xhtml-theme.html), and others, 
 > it is really designed to work best with the [ajax theme](ajax-theme.html). 
 > We recommend reading the 
 > _ajax a template_  documentation for more details.
 
 ## Parameters
 
-~~~~~~~
-{snippet:id=tagattributes|javadoc=false|url=struts2-tags/a.html}
-~~~~~~~
+{% tag_parameters a.html %}
 
 ## Usage
 
 To get started, use the [head](head-tag.htlm) tag and the [ajax 
theme](ajax-theme.html). See _ajax head template_  
 for more information. Then look at the usage details for the _ajax a template_ 
.
 
-If you want to use additional parameters in your s:a the best practice is to 
use a s:url to create your url and then 
-leverage this url into your s:a tag. This is done by creating a s:url and 
specifying an id attribute. like "testUrlId" 
-in this example. Then in the s:a tag reference this id in the href attribute 
via `%{testUrlId}`
+If you want to use additional parameters in your `s:a` the best practice is to 
use a `s:url` to create your url and then 
+leverage this url into your `s:a` tag. This is done by creating a `s:url` and 
specifying an `var` attribute. Like `testUrlId` 
+in this example. Then in the `s:a` tag reference this id in the href attribute 
via `%{testUrlId}`
 
 ```jsp
 <s:url var="testUrlId" namespace="/subscriber" action="customField" 
method="delete">
     <s:param name="customFieldDefinition.id" value="${id}"/>
 </s:url>
+
 <s:a errorText="Sorry your request had an error." preInvokeJS="confirm('Are 
you sure you want to delete this item?')" href="%{testUrlId}">
     <img src="<s:url value="/images/delete.gif"/>" border="none"/>
 </s:a>
 
-<img xsrc="<s:url value="/images/delete.gif"/>" border="none"/><s:a><img 
xsrc="<s:url value="/images/delete.gif"/>" border="none"/></s:a>
+<img xsrc="<s:url value="/images/delete.gif"/>" border="none"/>
+
+<s:a><img xsrc="<s:url value="/images/delete.gif"/>" border="none"/></s:a>  
 ```

Reply via email to