Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Block-based API for writing anchor elements.

  • Loading branch information...
commit 62da5a72e0fdb6bfdf4b07275fe9474bab1b18e8 1 parent 1b3d197
@mikeabdullah mikeabdullah authored
Showing with 16 additions and 2 deletions.
  1. +5 −1 KSHTMLWriter.h
  2. +11 −1 KSHTMLWriter.m
View
6 KSHTMLWriter.h
@@ -97,7 +97,11 @@ extern NSString *KSHTMLWriterDocTypeHTML_5;
#pragma mark Links
// <a href="...." target="..." rel="nofollow">
-- (void)startAnchorElementWithHref:(NSString *)href title:(NSString *)titleString target:(NSString *)targetString rel:(NSString *)relString;
+- (void)writeAnchorElementWithHref:(NSString *)href
+ title:(NSString *)titleString
+ target:(NSString *)targetString
+ rel:(NSString *)relString
+ content:(void (^)(void))content; // a block must provided - an empty anchor doesn't make sense!
#pragma mark Images
View
12 KSHTMLWriter.m
@@ -203,10 +203,11 @@ - (void)writeLineBreak;
[self endElement];
}
-#pragma mark Higher-level Tag Writing
+#pragma mark Anchors
- (void)startAnchorElementWithHref:(NSString *)href title:(NSString *)titleString target:(NSString *)targetString rel:(NSString *)relString;
{
+ // TODO: Remove this method once Sandvox no longer needs it
if (href) [self pushAttribute:@"href" value:href];
if (targetString) [self pushAttribute:@"target" value:targetString];
if (titleString) [self pushAttribute:@"title" value:titleString];
@@ -215,6 +216,15 @@ - (void)startAnchorElementWithHref:(NSString *)href title:(NSString *)titleStrin
[self startElement:@"a"];
}
+- (void)writeAnchorElementWithHref:(NSString *)href title:(NSString *)titleString target:(NSString *)targetString rel:(NSString *)relString content:(void (^)(void))content;
+{
+ [self startAnchorElementWithHref:href title:titleString target:targetString rel:relString];
+ content();
+ [self endElement];
+}
+
+#pragma mark Images
+
- (void)writeImageWithSrc:(NSString *)src
alt:(NSString *)alt
width:(id)width
Please sign in to comment.
Something went wrong with that request. Please try again.