An object is a collection of related data and/or functionality (which usually consists of several variables and functions — which are called properties and methods when they are inside objects.)
In Tiddlywiki a tiddler is an object
created: 20191214183217169
modified: 20191214183238380
tags:
title: A
My A Text
{{||B}}created: 20191214183240503
modified: 20191214183314068
stuff: b stuff
tags:
title: B
{{!!stuff}}created: 20191214183316677
modified: 20191214183349224
stuff: inheritance stuff
tags:
title: inheritance
{{||A}}In Tiddlywiki tiddler fields act as object properties and macros inside tiddler act as object's methods
Sure, a little.Any tiddler could be thought of as an object, where the fields are properties.In terms of inheritance, there's a design pattern for "having a ..." (which I'll call HA). The HA pattern turns out to often be more useful than conventional inheritance. And it can be emulated with transclusion in TW.tiddler A:created: 20191214183217169
modified: 20191214183238380
tags:
title: A
My A Text
{{||B}}
tiddler B:
created: 20191214183217169
modified: 20191214183238380
tags:
title: A
My A Text
{{||B}}
The invoking tiddler, that "inherits" properties from A and B :
This example shows how simple a tiddler can inherits from another tiddler.
A base object here is called btn-base implements css for a button. This tiddler is called the base class.
.{{!!btn-class}} { background-color: {{!!btn-background}}; color: {{!!btn-color}}; text-align: center; text-decoration: none; display: inline-block; border: none; padding: 15px 32px; font-size: 16px; }
It contains below fields
- btn-color
- white
- btn-class
- btn-base
- btn-background
- #4CAF50
Lets create a button using the button class implemented in btn-base
<$button class="btn-base" >
Press me!
</$button>
That renders as:
Here two new objects called btn-red and btn-blue are created as bellow
{{||btn-base}}
It contains the below fields
- btn-color
- white
- btn-class
- btn-red
- btn-background
- red
As it is seen btn-red uses simple transclusion to inherit the CSS defined in the btn-base
btn-red)Use the new CSS class (objects) for styling new buttons.
<$button class="btn-red" >
Press me!
</$button>
<$button class="btn-blue" >
Press me!
</$button>
That renders as:
I love this abstract thinking and do it a lot myself.
Keep in mind the same "method" can be applied to more than one tiddler. To me macros and buttons can do this and in some ways transcluding a special tiddler (like an object) via the view template conditionally can apply a method to a tiddler.
My recent use of storyTiddler allows you to coopt current tiddler as a parameter to a "method" e.g.
{{Param||methodtiddler}} in wich current tiddler becomes Params tiddler has the login and the real current tiddler is in storyTiddler variable. You can access all fields on the storytiddler, or the param tiddler and with and additional variable the methodtiddlers fields.
One coding practice of mine is to avoid the use of the text field on working tiddlers to reserve it for notes so I have to use the view template to display tiddler content.
Of interest with method tiddlers that have wiki text code in them you can define macros, introduce styles, wiki text and widgets in a single tiddler.
I am currently researching code patterns to ensure this approach is comprehensive and without gaps.
One gap I am working on is automating the setting some fields based on a value in a variable for widgets that only accept fields or text references. To do this I need to use the open tiddler trigger.
Another endeavour of mine is to make use of existing triggers usually in existing buttons to trigger additional actions to reduce the need for additional triggers the user needs to pull. I am somewhat slowed down on this because its similar but different to Jeremy s project to allow widgets to have custom actions.
Regards
Tony
FolksI love this abstract thinking and do it a lot myself.
Keep in mind the same "method" can be applied to more than one tiddler. To me macros and buttons can do this and in some ways transcluding a special tiddler (like an object) via the view template conditionally can apply a method to a tiddler.
My recent use of storyTiddler allows you to coopt current tiddler as a parameter to a "method" e.g.
{{Param||methodtiddler}} in wich current tiddler becomes Params tiddler has the login and the real current tiddler is in storyTiddler variable. You can access all fields on the storytiddler, or the param tiddler and with and additional variable the methodtiddlers fields.One coding practice of mine is to avoid the use of the text field on working tiddlers to reserve it for notes so I have to use the view template to display tiddler content.
Of interest with method tiddlers that have wiki text code in them you can define macros, introduce styles, wiki text and widgets in a single tiddler.
I am currently researching code patterns to ensure this approach is comprehensive and without gaps.
One gap I am working on is automating the setting some fields based on a value in a variable for widgets that only accept fields or text references. To do this I need to use the open tiddler trigger.
Another endeavour of mine is to make use of existing triggers usually in existing buttons to trigger additional actions to reduce the need for additional triggers the user needs to pull. I am somewhat slowed down on this because its similar but different to Jeremy s project to allow widgets to have custom actions.
Regards
Tony
In my opinion Tiddlywiki has amazing feature but most of them are not documented or under-documented!