Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 99 lines (84 sloc) 3.607 kB
ed26c85 @groue v5.3.0
authored
1 // The MIT License
2 //
3 // Copyright (c) 2012 Gwendal Roué
4 //
5 // Permission is hereby granted, free of charge, to any person obtaining a copy
6 // of this software and associated documentation files (the "Software"), to deal
7 // in the Software without restriction, including without limitation the rights
8 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 // copies of the Software, and to permit persons to whom the Software is
10 // furnished to do so, subject to the following conditions:
11 //
12 // The above copyright notice and this permission notice shall be included in
13 // all copies or substantial portions of the Software.
14 //
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 // THE SOFTWARE.
22
23 #import <Foundation/Foundation.h>
24 #import "GRMustacheAvailabilityMacros.h"
25
26 @class GRMustacheSectionTagRenderingContext;
27
28
29 // =============================================================================
30 #pragma mark - <GRMustacheSectionTagHelper>
31
32 /**
33 * The protocol for implementing Section tag helpers.
34 *
35 * The responsability of a GRMustacheSectionTagHelper is to render a Mustache
36 * section such as `{{#bold}}...{{/bold}}`.
37 *
38 * When the data given to a Mustache section is a GRMustacheSectionTagHelper,
39 * GRMustache invokes the `renderForSectionTagInContext:` method of the helper,
40 * and inserts the raw return value in the final rendering.
41 *
42 * **Companion guide:** https://github.com/groue/GRMustache/blob/master/Guides/section_tag_helpers.md
43 *
44 * @since v5.3
45 */
46 @protocol GRMustacheSectionTagHelper<NSObject>
47 @required
48
49 ////////////////////////////////////////////////////////////////////////////////
50 /// @name Rendering Sections
51 ////////////////////////////////////////////////////////////////////////////////
52
53 /**
54 * Returns the rendering of a Mustache section.
55 *
56 * @param context A section tag rendering context
57 *
58 * @return The rendering of the section
59 *
60 * @since v5.3
61 */
62 - (NSString *)renderForSectionTagInContext:(GRMustacheSectionTagRenderingContext *)context AVAILABLE_GRMUSTACHE_VERSION_5_3_AND_LATER;
63 @end
64
65
66 // =============================================================================
67 #pragma mark - GRMustacheSectionTagHelper
68
69 /**
70 * The GRMustacheSectionTagHelper class helps building mustache helpers without
71 * writing a custom class that conforms to the GRMustacheSectionTagHelper protocol.
72 *
73 * **Companion guide:** https://github.com/groue/GRMustache/blob/master/Guides/section_tag_helpers.md
74 *
75 * @see GRMustacheSectionTagHelper protocol
76 *
77 * @since v5.3
78 */
79 @interface GRMustacheSectionTagHelper: NSObject<GRMustacheSectionTagHelper>
80
81 ////////////////////////////////////////////////////////////////////////////////
82 /// @name Creating Helpers
83 ////////////////////////////////////////////////////////////////////////////////
84
85 /**
86 * Returns a GRMustacheSectionTagHelper object that executes the provided block
87 * when rendering a Mustache section.
88 *
89 * @param block The block that renders a section.
90 *
91 * @return a GRMustacheSectionTagHelper object.
92 *
93 * @since v5.3
94 */
95 + (id)helperWithBlock:(NSString *(^)(GRMustacheSectionTagRenderingContext* context))block AVAILABLE_GRMUSTACHE_VERSION_5_3_AND_LATER;
96
97 @end
98
Something went wrong with that request. Please try again.